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

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

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

@ -126,20 +126,17 @@ namespace MediaBrowser.Controller.Entities
/// <summary>
/// Never want folders to be blocked by "BlockNotRated"
/// </summary>
public override string OfficialRating
[IgnoreDataMember]
public override string OfficialRatingForComparison
{
get
{
if (this is Series)
{
return base.OfficialRating;
return base.OfficialRatingForComparison;
}
return !string.IsNullOrEmpty(base.OfficialRating) ? base.OfficialRating : "None";
}
set
{
base.OfficialRating = value;
return !string.IsNullOrEmpty(base.OfficialRatingForComparison) ? base.OfficialRatingForComparison : "None";
}
}
@ -316,9 +313,9 @@ namespace MediaBrowser.Controller.Entities
{
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()
.Select(i =>
{
@ -338,7 +335,7 @@ namespace MediaBrowser.Controller.Entities
}
})
.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");
//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()
.Select(i =>
{
@ -378,7 +375,7 @@ namespace MediaBrowser.Controller.Entities
}
})
.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;
Genres = ShadowItem.Genres;
Studios = ShadowItem.Studios;
OfficialRating = ShadowItem.OfficialRating;
OfficialRating = ShadowItem.OfficialRatingForComparison;
BackdropImagePaths = ShadowItem.BackdropImagePaths;
Images = ShadowItem.Images;
Overview = ShadowItem.Overview;

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

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

Loading…
Cancel
Save