reduced some virtualization

pull/702/head
Luke Pulverenti 11 years ago
parent a52ea4cf08
commit 0e4972f7e6

@ -1,7 +1,8 @@
using System.Collections.Generic; using MediaBrowser.Model.Entities;
using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Controller.Entities.Audio namespace MediaBrowser.Controller.Entities.Audio
{ {
@ -79,9 +80,11 @@ namespace MediaBrowser.Controller.Entities.Audio
{ {
get get
{ {
var child = Children.FirstOrDefault(); return Children
.OfType<Audio>()
return child == null ? base.Genres : child.Genres; .SelectMany(i => i.Genres)
.Distinct(StringComparer.OrdinalIgnoreCase)
.ToList();
} }
set set
{ {

@ -14,9 +14,10 @@ namespace MediaBrowser.Controller.Entities.Audio
get get
{ {
return Children return Children
.SelectMany(i => i.Genres) .OfType<MusicAlbum>()
.Distinct(StringComparer.OrdinalIgnoreCase) .SelectMany(i => i.Genres)
.ToList(); .Distinct(StringComparer.OrdinalIgnoreCase)
.ToList();
} }
set set
{ {

@ -469,7 +469,7 @@ namespace MediaBrowser.Controller.Entities
/// Gets or sets the official rating. /// Gets or sets the official rating.
/// </summary> /// </summary>
/// <value>The official rating.</value> /// <value>The official rating.</value>
public virtual string OfficialRating { get; set; } public string OfficialRating { get; set; }
/// <summary> /// <summary>
/// Gets or sets the official rating description. /// Gets or sets the official rating description.
@ -481,7 +481,7 @@ namespace MediaBrowser.Controller.Entities
/// Gets or sets the custom rating. /// Gets or sets the custom rating.
/// </summary> /// </summary>
/// <value>The custom rating.</value> /// <value>The custom rating.</value>
public virtual string CustomRating { get; set; } public string CustomRating { get; set; }
/// <summary> /// <summary>
/// Gets or sets the language. /// Gets or sets the language.
@ -521,6 +521,18 @@ namespace MediaBrowser.Controller.Entities
get { return People; } get { return People; }
} }
[IgnoreDataMember]
public virtual IEnumerable<string> AllStudios
{
get { return Studios; }
}
[IgnoreDataMember]
public virtual IEnumerable<string> AllGenres
{
get { return Genres; }
}
/// <summary> /// <summary>
/// Gets or sets the studios. /// Gets or sets the studios.
/// </summary> /// </summary>
@ -620,6 +632,18 @@ namespace MediaBrowser.Controller.Entities
public List<Guid> ThemeVideoIds { get; set; } public List<Guid> ThemeVideoIds { get; set; }
public List<Guid> LocalTrailerIds { get; set; } public List<Guid> LocalTrailerIds { get; set; }
[IgnoreDataMember]
public virtual string OfficialRatingForComparison
{
get { return OfficialRating; }
}
[IgnoreDataMember]
public virtual string CustomRatingForComparison
{
get { return CustomRating; }
}
/// <summary> /// <summary>
/// Loads local trailers from the file system /// Loads local trailers from the file system
/// </summary> /// </summary>
@ -992,11 +1016,11 @@ namespace MediaBrowser.Controller.Entities
return true; return true;
} }
var rating = CustomRating; var rating = CustomRatingForComparison;
if (string.IsNullOrEmpty(rating)) if (string.IsNullOrEmpty(rating))
{ {
rating = OfficialRating; rating = OfficialRatingForComparison;
} }
if (string.IsNullOrEmpty(rating)) if (string.IsNullOrEmpty(rating))

@ -126,20 +126,17 @@ namespace MediaBrowser.Controller.Entities
/// <summary> /// <summary>
/// Never want folders to be blocked by "BlockNotRated" /// Never want folders to be blocked by "BlockNotRated"
/// </summary> /// </summary>
public override string OfficialRating [IgnoreDataMember]
public override string OfficialRatingForComparison
{ {
get get
{ {
if (this is Series) if (this is Series)
{ {
return base.OfficialRating; return base.OfficialRatingForComparison;
} }
return !string.IsNullOrEmpty(base.OfficialRating) ? base.OfficialRating : "None"; return !string.IsNullOrEmpty(base.OfficialRatingForComparison) ? base.OfficialRatingForComparison : "None";
}
set
{
base.OfficialRating = value;
} }
} }
@ -316,9 +313,9 @@ namespace MediaBrowser.Controller.Entities
{ {
var indexName = LocalizedStrings.Instance.GetString("StudioDispPref"); var indexName = LocalizedStrings.Instance.GetString("StudioDispPref");
var candidates = GetRecursiveChildren(user).Where(i => i.IncludeInIndex && i.Studios != null).ToList(); var candidates = GetRecursiveChildren(user).Where(i => i.IncludeInIndex).ToList();
return candidates.AsParallel().SelectMany(i => i.Studios) return candidates.AsParallel().SelectMany(i => i.AllStudios)
.Distinct() .Distinct()
.Select(i => .Select(i =>
{ {
@ -338,7 +335,7 @@ namespace MediaBrowser.Controller.Entities
} }
}) })
.Where(i => i != null) .Where(i => i != null)
.Select(ndx => new IndexFolder(this, ndx, candidates.Where(i => i.Studios.Any(s => s.Equals(ndx.Name, StringComparison.OrdinalIgnoreCase))), indexName)); .Select(ndx => new IndexFolder(this, ndx, candidates.Where(i => i.AllStudios.Any(s => s.Equals(ndx.Name, StringComparison.OrdinalIgnoreCase))), indexName));
} }
} }
@ -356,9 +353,9 @@ namespace MediaBrowser.Controller.Entities
var indexName = LocalizedStrings.Instance.GetString("GenreDispPref"); var indexName = LocalizedStrings.Instance.GetString("GenreDispPref");
//we need a copy of this so we don't double-recurse //we need a copy of this so we don't double-recurse
var candidates = GetRecursiveChildren(user).Where(i => i.IncludeInIndex && i.Genres != null).ToList(); var candidates = GetRecursiveChildren(user).Where(i => i.IncludeInIndex).ToList();
return candidates.AsParallel().SelectMany(i => i.Genres) return candidates.AsParallel().SelectMany(i => i.AllGenres)
.Distinct() .Distinct()
.Select(i => .Select(i =>
{ {
@ -378,7 +375,7 @@ namespace MediaBrowser.Controller.Entities
} }
}) })
.Where(i => i != null) .Where(i => i != null)
.Select(genre => new IndexFolder(this, genre, candidates.Where(i => i.Genres.Any(g => g.Equals(genre.Name, StringComparison.OrdinalIgnoreCase))), indexName) .Select(genre => new IndexFolder(this, genre, candidates.Where(i => i.AllGenres.Any(g => g.Equals(genre.Name, StringComparison.OrdinalIgnoreCase))), indexName)
); );
} }
} }

@ -181,7 +181,7 @@ namespace MediaBrowser.Controller.Entities
ForcedSortName = ShadowItem.SortName; ForcedSortName = ShadowItem.SortName;
Genres = ShadowItem.Genres; Genres = ShadowItem.Genres;
Studios = ShadowItem.Studios; Studios = ShadowItem.Studios;
OfficialRating = ShadowItem.OfficialRating; OfficialRating = ShadowItem.OfficialRatingForComparison;
BackdropImagePaths = ShadowItem.BackdropImagePaths; BackdropImagePaths = ShadowItem.BackdropImagePaths;
Images = ShadowItem.Images; Images = ShadowItem.Images;
Overview = ShadowItem.Overview; Overview = ShadowItem.Overview;

@ -73,59 +73,42 @@ namespace MediaBrowser.Controller.Entities.TV
} }
} }
/// <summary>
/// Gets or sets the studios.
/// </summary>
/// <value>The studios.</value>
[IgnoreDataMember] [IgnoreDataMember]
public override List<string> Studios public override IEnumerable<string> AllGenres
{ {
get get
{ {
return Series != null ? Series.Studios : null; if (Genres == null) return Series != null ? Series.Genres : Genres;
} return Series != null && Series.Genres != null ? Genres.Concat(Series.Genres) : base.AllGenres;
set
{
base.Studios = value;
} }
} }
/// <summary>
/// Gets or sets the genres.
/// </summary>
/// <value>The genres.</value>
[IgnoreDataMember] [IgnoreDataMember]
public override List<string> Genres public override IEnumerable<string> AllStudios
{ {
get { return Series != null ? Series.Genres : null; } get
set
{ {
base.Genres = value; if (Studios == null) return Series != null ? Series.Studios : Studios;
return Series != null && Series.Studios != null ? Studios.Concat(Series.Studios) : base.AllStudios;
} }
} }
/// <summary> /// <summary>
/// Our rating comes from our series /// Our rating comes from our series
/// </summary> /// </summary>
public override string OfficialRating [IgnoreDataMember]
public override string OfficialRatingForComparison
{ {
get { return Series != null ? Series.OfficialRating : base.OfficialRating; } get { return Series != null ? Series.OfficialRatingForComparison : base.OfficialRatingForComparison; }
set
{
base.OfficialRating = value;
}
} }
/// <summary> /// <summary>
/// Our rating comes from our series /// Our rating comes from our series
/// </summary> /// </summary>
public override string CustomRating [IgnoreDataMember]
public override string CustomRatingForComparison
{ {
get { return Series != null ? Series.CustomRating : base.CustomRating; } get { return Series != null ? Series.CustomRatingForComparison : base.CustomRatingForComparison; }
set
{
base.CustomRating = value;
}
} }
/// <summary> /// <summary>

@ -96,25 +96,19 @@ namespace MediaBrowser.Controller.Entities.TV
/// <summary> /// <summary>
/// Our rating comes from our series /// Our rating comes from our series
/// </summary> /// </summary>
public override string OfficialRating [IgnoreDataMember]
public override string OfficialRatingForComparison
{ {
get { return Series != null ? Series.OfficialRating : base.OfficialRating; } get { return Series != null ? Series.OfficialRatingForComparison : base.OfficialRatingForComparison; }
set
{
base.OfficialRating = value;
}
} }
/// <summary> /// <summary>
/// Our rating comes from our series /// Our rating comes from our series
/// </summary> /// </summary>
public override string CustomRating [IgnoreDataMember]
public override string CustomRatingForComparison
{ {
get { return Series != null ? Series.CustomRating : base.CustomRating; } get { return Series != null ? Series.CustomRatingForComparison : base.CustomRatingForComparison; }
set
{
base.CustomRating = value;
}
} }
/// <summary> /// <summary>

Loading…
Cancel
Save