improved performance of item counts

This commit is contained in:
Luke Pulverenti
2013-09-11 13:54:59 -04:00
parent 1496991096
commit 803e8b4a2e
49 changed files with 496 additions and 380 deletions

View File

@@ -12,7 +12,6 @@ namespace MediaBrowser.Controller.Entities.Audio
{
public Artist()
{
ItemCounts = new ItemByNameCounts();
UserItemCounts = new Dictionary<Guid, ItemByNameCounts>();
}
@@ -27,9 +26,6 @@ namespace MediaBrowser.Controller.Entities.Audio
return "Artist-" + Name;
}
[IgnoreDataMember]
public ItemByNameCounts ItemCounts { get; set; }
[IgnoreDataMember]
public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; }
}

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
@@ -11,7 +12,7 @@ namespace MediaBrowser.Controller.Entities.Audio
{
public MusicAlbum()
{
Artists = new string[] { };
Artists = new List<string>();
}
public string LastFmImageUrl { get; set; }
@@ -72,7 +73,7 @@ namespace MediaBrowser.Controller.Entities.Audio
public string AlbumArtist { get; set; }
public string[] Artists { get; set; }
public List<string> Artists { get; set; }
}
public class MusicAlbumDisc : Folder

View File

@@ -12,7 +12,6 @@ namespace MediaBrowser.Controller.Entities.Audio
{
public MusicGenre()
{
ItemCounts = new ItemByNameCounts();
UserItemCounts = new Dictionary<Guid, ItemByNameCounts>();
}
@@ -25,9 +24,6 @@ namespace MediaBrowser.Controller.Entities.Audio
return "MusicGenre-" + Name;
}
[IgnoreDataMember]
public ItemByNameCounts ItemCounts { get; set; }
[IgnoreDataMember]
public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; }
}

View File

@@ -31,10 +31,8 @@ namespace MediaBrowser.Controller.Entities
protected BaseItem()
{
Genres = new List<string>();
RemoteTrailers = new List<MediaUrl>();
Studios = new List<string>();
People = new List<PersonInfo>();
Taglines = new List<string>();
ScreenshotImagePaths = new List<string>();
BackdropImagePaths = new List<string>();
ProductionLocations = new List<string>();
@@ -46,6 +44,8 @@ namespace MediaBrowser.Controller.Entities
SoundtrackIds = new List<Guid>();
LocalTrailerIds = new List<Guid>();
LockedFields = new List<MetadataFields>();
Taglines = new List<string>();
RemoteTrailers = new List<MediaUrl>();
}
/// <summary>
@@ -90,6 +90,42 @@ namespace MediaBrowser.Controller.Entities
/// <value>The id.</value>
public Guid Id { get; set; }
/// <summary>
/// Gets or sets the budget.
/// </summary>
/// <value>The budget.</value>
public double? Budget { get; set; }
/// <summary>
/// Gets or sets the taglines.
/// </summary>
/// <value>The taglines.</value>
public List<string> Taglines { get; set; }
/// <summary>
/// Gets or sets the revenue.
/// </summary>
/// <value>The revenue.</value>
public double? Revenue { get; set; }
/// <summary>
/// Gets or sets the critic rating.
/// </summary>
/// <value>The critic rating.</value>
public float? CriticRating { get; set; }
/// <summary>
/// Gets or sets the critic rating summary.
/// </summary>
/// <value>The critic rating summary.</value>
public string CriticRatingSummary { get; set; }
/// <summary>
/// Gets or sets the trailer URL.
/// </summary>
/// <value>The trailer URL.</value>
public List<MediaUrl> RemoteTrailers { get; set; }
/// <summary>
/// Return the id that should be used to key display prefs for this item.
/// Default is based on the type for everything except actual generic folders.
@@ -522,11 +558,6 @@ namespace MediaBrowser.Controller.Entities
/// </summary>
/// <value>The overview.</value>
public string Overview { get; set; }
/// <summary>
/// Gets or sets the taglines.
/// </summary>
/// <value>The taglines.</value>
public List<string> Taglines { get; set; }
/// <summary>
/// Gets or sets the people.
@@ -580,36 +611,12 @@ namespace MediaBrowser.Controller.Entities
/// <value>The home page URL.</value>
public string HomePageUrl { get; set; }
/// <summary>
/// Gets or sets the budget.
/// </summary>
/// <value>The budget.</value>
public double? Budget { get; set; }
/// <summary>
/// Gets or sets the revenue.
/// </summary>
/// <value>The revenue.</value>
public double? Revenue { get; set; }
/// <summary>
/// Gets or sets the production locations.
/// </summary>
/// <value>The production locations.</value>
public List<string> ProductionLocations { get; set; }
/// <summary>
/// Gets or sets the critic rating.
/// </summary>
/// <value>The critic rating.</value>
public float? CriticRating { get; set; }
/// <summary>
/// Gets or sets the critic rating summary.
/// </summary>
/// <value>The critic rating summary.</value>
public string CriticRatingSummary { get; set; }
/// <summary>
/// Gets or sets the community rating.
/// </summary>
@@ -973,12 +980,6 @@ namespace MediaBrowser.Controller.Entities
return themeSongsChanged || results.Contains(true);
}
/// <summary>
/// Gets or sets the trailer URL.
/// </summary>
/// <value>The trailer URL.</value>
public List<MediaUrl> RemoteTrailers { get; set; }
/// <summary>
/// Gets or sets the provider ids.
/// </summary>
@@ -1255,53 +1256,6 @@ namespace MediaBrowser.Controller.Entities
}
}
/// <summary>
/// Adds a tagline to the item
/// </summary>
/// <param name="name">The name.</param>
/// <exception cref="System.ArgumentNullException"></exception>
public void AddTagline(string name)
{
if (string.IsNullOrWhiteSpace(name))
{
throw new ArgumentNullException("name");
}
if (!Taglines.Contains(name, StringComparer.OrdinalIgnoreCase))
{
Taglines.Add(name);
}
}
/// <summary>
/// Adds a TrailerUrl to the item
/// </summary>
/// <param name="url">The URL.</param>
/// <param name="isDirectLink">if set to <c>true</c> [is direct link].</param>
/// <exception cref="System.ArgumentNullException">url</exception>
public void AddTrailerUrl(string url, bool isDirectLink)
{
if (string.IsNullOrWhiteSpace(url))
{
throw new ArgumentNullException("url");
}
var current = RemoteTrailers.FirstOrDefault(i => string.Equals(i.Url, url, StringComparison.OrdinalIgnoreCase));
if (current != null)
{
current.IsDirectLink = isDirectLink;
}
else
{
RemoteTrailers.Add(new MediaUrl
{
Url = url,
IsDirectLink = isDirectLink
});
}
}
/// <summary>
/// Adds a genre to the item
/// </summary>
@@ -1545,7 +1499,6 @@ namespace MediaBrowser.Controller.Entities
{
// Only validate paths from the same directory - need to copy to a list because we are going to potentially modify the collection below
var deletedKeys = Images
.ToList()
.Where(image => !File.Exists(image.Value))
.Select(i => i.Key)
.ToList();

View File

@@ -0,0 +1,51 @@
using MediaBrowser.Model.Entities;
using System;
using System.Linq;
namespace MediaBrowser.Controller.Entities
{
public static class Extensions
{
/// <summary>
/// Adds the tagline.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="tagline">The tagline.</param>
/// <exception cref="System.ArgumentNullException">tagline</exception>
public static void AddTagline(this BaseItem item, string tagline)
{
if (string.IsNullOrWhiteSpace(tagline))
{
throw new ArgumentNullException("tagline");
}
if (!item.Taglines.Contains(tagline, StringComparer.OrdinalIgnoreCase))
{
item.Taglines.Add(tagline);
}
}
public static void AddTrailerUrl(this BaseItem item, string url, bool isDirectLink)
{
if (string.IsNullOrWhiteSpace(url))
{
throw new ArgumentNullException("url");
}
var current = item.RemoteTrailers.FirstOrDefault(i => string.Equals(i.Url, url, StringComparison.OrdinalIgnoreCase));
if (current != null)
{
current.IsDirectLink = isDirectLink;
}
else
{
item.RemoteTrailers.Add(new MediaUrl
{
Url = url,
IsDirectLink = isDirectLink
});
}
}
}
}

View File

@@ -499,7 +499,7 @@ namespace MediaBrowser.Controller.Entities
{
get
{
return ActualChildren.Values.ToList();
return ActualChildren.Values.ToArray();
}
}
@@ -757,7 +757,7 @@ namespace MediaBrowser.Controller.Entities
{
var list = children.ToList();
var percentages = new Dictionary<Guid, double>();
var percentages = new Dictionary<Guid, double>(list.Count);
var tasks = new List<Task>();

View File

@@ -9,7 +9,6 @@ namespace MediaBrowser.Controller.Entities
{
public GameGenre()
{
ItemCounts = new ItemByNameCounts();
UserItemCounts = new Dictionary<Guid, ItemByNameCounts>();
}
@@ -22,9 +21,6 @@ namespace MediaBrowser.Controller.Entities
return "GameGenre-" + Name;
}
[IgnoreDataMember]
public ItemByNameCounts ItemCounts { get; set; }
[IgnoreDataMember]
public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; }
}

View File

@@ -12,7 +12,6 @@ namespace MediaBrowser.Controller.Entities
{
public Genre()
{
ItemCounts = new ItemByNameCounts();
UserItemCounts = new Dictionary<Guid, ItemByNameCounts>();
}
@@ -25,9 +24,6 @@ namespace MediaBrowser.Controller.Entities
return "Genre-" + Name;
}
[IgnoreDataMember]
public ItemByNameCounts ItemCounts { get; set; }
[IgnoreDataMember]
public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; }
}

View File

@@ -9,8 +9,6 @@ namespace MediaBrowser.Controller.Entities
/// </summary>
public interface IItemByName
{
ItemByNameCounts ItemCounts { get; set; }
Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; }
}
@@ -20,7 +18,7 @@ namespace MediaBrowser.Controller.Entities
{
if (user == null)
{
return item.ItemCounts;
throw new ArgumentNullException("user");
}
ItemByNameCounts counts;

View File

@@ -12,13 +12,9 @@ namespace MediaBrowser.Controller.Entities
{
public Person()
{
ItemCounts = new ItemByNameCounts();
UserItemCounts = new Dictionary<Guid, ItemByNameCounts>();
}
[IgnoreDataMember]
public ItemByNameCounts ItemCounts { get; set; }
[IgnoreDataMember]
public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; }

View File

@@ -12,7 +12,6 @@ namespace MediaBrowser.Controller.Entities
{
public Studio()
{
ItemCounts = new ItemByNameCounts();
UserItemCounts = new Dictionary<Guid, ItemByNameCounts>();
}
@@ -25,9 +24,6 @@ namespace MediaBrowser.Controller.Entities
return "Studio-" + Name;
}
[IgnoreDataMember]
public ItemByNameCounts ItemCounts { get; set; }
[IgnoreDataMember]
public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; }
}

View File

@@ -1,5 +1,6 @@
using System.Runtime.Serialization;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Entities;
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace MediaBrowser.Controller.Entities
{
@@ -8,6 +9,12 @@ namespace MediaBrowser.Controller.Entities
/// </summary>
public class Trailer : Video
{
public Trailer()
{
RemoteTrailers = new List<MediaUrl>();
Taglines = new List<string>();
}
/// <summary>
/// Gets a value indicating whether this instance is local trailer.
/// </summary>

View File

@@ -12,13 +12,9 @@ namespace MediaBrowser.Controller.Entities
{
public Year()
{
ItemCounts = new ItemByNameCounts();
UserItemCounts = new Dictionary<Guid, ItemByNameCounts>();
}
[IgnoreDataMember]
public ItemByNameCounts ItemCounts { get; set; }
[IgnoreDataMember]
public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; }

View File

@@ -48,6 +48,8 @@ namespace MediaBrowser.Controller.Library
/// <value>The root folder.</value>
AggregateFolder RootFolder { get; }
Person GetPersonSync(string name);
/// <summary>
/// Gets a Person
/// </summary>

View File

@@ -245,7 +245,7 @@ namespace MediaBrowser.Controller.Library
{
throw new ArgumentNullException();
}
if (MetadataFileDictionary == null)
{
MetadataFileDictionary = new Dictionary<string, FileSystemInfo>(StringComparer.OrdinalIgnoreCase);

View File

@@ -78,6 +78,7 @@
<Compile Include="Entities\Book.cs" />
<Compile Include="Configuration\IServerConfigurationManager.cs" />
<Compile Include="Entities\Audio\MusicGenre.cs" />
<Compile Include="Entities\Extensions.cs" />
<Compile Include="Entities\Game.cs" />
<Compile Include="Entities\GameGenre.cs" />
<Compile Include="Entities\IByReferenceItem.cs" />