diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-09-11 13:54:59 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-09-11 13:54:59 -0400 |
| commit | 803e8b4a2eb5fcf1b5a3679fe551d541620d4743 (patch) | |
| tree | 8d070a411db7406fe5e7f30e03feefe83ad7127d /MediaBrowser.Controller/Entities | |
| parent | 1496991096c4db9f69bc572aeefc8099ca0f0c01 (diff) | |
improved performance of item counts
Diffstat (limited to 'MediaBrowser.Controller/Entities')
| -rw-r--r-- | MediaBrowser.Controller/Entities/Audio/Artist.cs | 4 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs | 5 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/Audio/MusicGenre.cs | 4 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/BaseItem.cs | 123 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/Extensions.cs | 51 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/Folder.cs | 4 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/GameGenre.cs | 4 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/Genre.cs | 4 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/IItemByName.cs | 4 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/Person.cs | 4 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/Studio.cs | 4 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/Trailer.cs | 11 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/Year.cs | 4 |
13 files changed, 104 insertions, 122 deletions
diff --git a/MediaBrowser.Controller/Entities/Audio/Artist.cs b/MediaBrowser.Controller/Entities/Audio/Artist.cs index 49aa9b525d..e0d80527cb 100644 --- a/MediaBrowser.Controller/Entities/Audio/Artist.cs +++ b/MediaBrowser.Controller/Entities/Audio/Artist.cs @@ -12,7 +12,6 @@ namespace MediaBrowser.Controller.Entities.Audio { public Artist() { - ItemCounts = new ItemByNameCounts(); UserItemCounts = new Dictionary<Guid, ItemByNameCounts>(); } @@ -28,9 +27,6 @@ namespace MediaBrowser.Controller.Entities.Audio } [IgnoreDataMember] - public ItemByNameCounts ItemCounts { get; set; } - - [IgnoreDataMember] public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; } } } diff --git a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs index 46b4bc73c8..0c88eed5b6 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs @@ -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 diff --git a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs index 5254a36bc4..ec2995fb2f 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs @@ -12,7 +12,6 @@ namespace MediaBrowser.Controller.Entities.Audio { public MusicGenre() { - ItemCounts = new ItemByNameCounts(); UserItemCounts = new Dictionary<Guid, ItemByNameCounts>(); } @@ -26,9 +25,6 @@ namespace MediaBrowser.Controller.Entities.Audio } [IgnoreDataMember] - public ItemByNameCounts ItemCounts { get; set; } - - [IgnoreDataMember] public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; } } } diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 4887af2cf3..84b6d80974 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -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> @@ -91,6 +91,42 @@ namespace MediaBrowser.Controller.Entities 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. /// </summary> @@ -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. @@ -581,36 +612,12 @@ namespace MediaBrowser.Controller.Entities 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> /// <value>The community rating.</value> @@ -974,12 +981,6 @@ namespace MediaBrowser.Controller.Entities } /// <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> /// <value>The provider ids.</value> @@ -1256,53 +1257,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> /// <param name="name">The name.</param> @@ -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(); diff --git a/MediaBrowser.Controller/Entities/Extensions.cs b/MediaBrowser.Controller/Entities/Extensions.cs new file mode 100644 index 0000000000..311e28cbb6 --- /dev/null +++ b/MediaBrowser.Controller/Entities/Extensions.cs @@ -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 + }); + } + } + } +} diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index bc009e5481..d7e1db7432 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -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>(); diff --git a/MediaBrowser.Controller/Entities/GameGenre.cs b/MediaBrowser.Controller/Entities/GameGenre.cs index b34df2abde..0c877782e6 100644 --- a/MediaBrowser.Controller/Entities/GameGenre.cs +++ b/MediaBrowser.Controller/Entities/GameGenre.cs @@ -9,7 +9,6 @@ namespace MediaBrowser.Controller.Entities { public GameGenre() { - ItemCounts = new ItemByNameCounts(); UserItemCounts = new Dictionary<Guid, ItemByNameCounts>(); } @@ -23,9 +22,6 @@ namespace MediaBrowser.Controller.Entities } [IgnoreDataMember] - public ItemByNameCounts ItemCounts { get; set; } - - [IgnoreDataMember] public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; } } } diff --git a/MediaBrowser.Controller/Entities/Genre.cs b/MediaBrowser.Controller/Entities/Genre.cs index 0aa4e478a9..71fa057206 100644 --- a/MediaBrowser.Controller/Entities/Genre.cs +++ b/MediaBrowser.Controller/Entities/Genre.cs @@ -12,7 +12,6 @@ namespace MediaBrowser.Controller.Entities { public Genre() { - ItemCounts = new ItemByNameCounts(); UserItemCounts = new Dictionary<Guid, ItemByNameCounts>(); } @@ -26,9 +25,6 @@ namespace MediaBrowser.Controller.Entities } [IgnoreDataMember] - public ItemByNameCounts ItemCounts { get; set; } - - [IgnoreDataMember] public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; } } } diff --git a/MediaBrowser.Controller/Entities/IItemByName.cs b/MediaBrowser.Controller/Entities/IItemByName.cs index ea23d7e3fc..7284bf101d 100644 --- a/MediaBrowser.Controller/Entities/IItemByName.cs +++ b/MediaBrowser.Controller/Entities/IItemByName.cs @@ -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; diff --git a/MediaBrowser.Controller/Entities/Person.cs b/MediaBrowser.Controller/Entities/Person.cs index 89ab2d2894..e5cf48ad08 100644 --- a/MediaBrowser.Controller/Entities/Person.cs +++ b/MediaBrowser.Controller/Entities/Person.cs @@ -12,14 +12,10 @@ 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; } /// <summary> diff --git a/MediaBrowser.Controller/Entities/Studio.cs b/MediaBrowser.Controller/Entities/Studio.cs index d3b3566615..bbe96a88b9 100644 --- a/MediaBrowser.Controller/Entities/Studio.cs +++ b/MediaBrowser.Controller/Entities/Studio.cs @@ -12,7 +12,6 @@ namespace MediaBrowser.Controller.Entities { public Studio() { - ItemCounts = new ItemByNameCounts(); UserItemCounts = new Dictionary<Guid, ItemByNameCounts>(); } @@ -26,9 +25,6 @@ namespace MediaBrowser.Controller.Entities } [IgnoreDataMember] - public ItemByNameCounts ItemCounts { get; set; } - - [IgnoreDataMember] public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; } } } diff --git a/MediaBrowser.Controller/Entities/Trailer.cs b/MediaBrowser.Controller/Entities/Trailer.cs index 044de3d6b5..e7d47f7ec7 100644 --- a/MediaBrowser.Controller/Entities/Trailer.cs +++ b/MediaBrowser.Controller/Entities/Trailer.cs @@ -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> diff --git a/MediaBrowser.Controller/Entities/Year.cs b/MediaBrowser.Controller/Entities/Year.cs index 737feb777c..d0f4577183 100644 --- a/MediaBrowser.Controller/Entities/Year.cs +++ b/MediaBrowser.Controller/Entities/Year.cs @@ -12,14 +12,10 @@ 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; } /// <summary> |
