diff --git a/MediaBrowser.Controller/Entities/Audio/Artist.cs b/MediaBrowser.Controller/Entities/Audio/Artist.cs index 3d2d41fb72..49aa9b525d 100644 --- a/MediaBrowser.Controller/Entities/Audio/Artist.cs +++ b/MediaBrowser.Controller/Entities/Audio/Artist.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Model.Dto; +using System.Runtime.Serialization; +using MediaBrowser.Model.Dto; using System; using System.Collections.Generic; @@ -26,8 +27,10 @@ namespace MediaBrowser.Controller.Entities.Audio return "Artist-" + Name; } + [IgnoreDataMember] public ItemByNameCounts ItemCounts { get; set; } + [IgnoreDataMember] public Dictionary UserItemCounts { get; set; } } } diff --git a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs index 3839f2a0ba..5254a36bc4 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Model.Dto; +using System.Runtime.Serialization; +using MediaBrowser.Model.Dto; using System; using System.Collections.Generic; @@ -24,8 +25,10 @@ namespace MediaBrowser.Controller.Entities.Audio return "MusicGenre-" + Name; } + [IgnoreDataMember] public ItemByNameCounts ItemCounts { get; set; } + [IgnoreDataMember] public Dictionary UserItemCounts { get; set; } } } diff --git a/MediaBrowser.Controller/Entities/GameGenre.cs b/MediaBrowser.Controller/Entities/GameGenre.cs index 7ae4f8f730..b34df2abde 100644 --- a/MediaBrowser.Controller/Entities/GameGenre.cs +++ b/MediaBrowser.Controller/Entities/GameGenre.cs @@ -1,6 +1,7 @@ using MediaBrowser.Model.Dto; using System; using System.Collections.Generic; +using System.Runtime.Serialization; namespace MediaBrowser.Controller.Entities { @@ -21,8 +22,10 @@ namespace MediaBrowser.Controller.Entities return "GameGenre-" + Name; } + [IgnoreDataMember] public ItemByNameCounts ItemCounts { get; set; } + [IgnoreDataMember] public Dictionary UserItemCounts { get; set; } } } diff --git a/MediaBrowser.Controller/Entities/Genre.cs b/MediaBrowser.Controller/Entities/Genre.cs index 83fa57dfba..0aa4e478a9 100644 --- a/MediaBrowser.Controller/Entities/Genre.cs +++ b/MediaBrowser.Controller/Entities/Genre.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Model.Dto; +using System.Runtime.Serialization; +using MediaBrowser.Model.Dto; using System; using System.Collections.Generic; @@ -24,8 +25,10 @@ namespace MediaBrowser.Controller.Entities return "Genre-" + Name; } + [IgnoreDataMember] public ItemByNameCounts ItemCounts { get; set; } + [IgnoreDataMember] public Dictionary UserItemCounts { get; set; } } } diff --git a/MediaBrowser.Controller/Entities/Person.cs b/MediaBrowser.Controller/Entities/Person.cs index 3e07984358..89ab2d2894 100644 --- a/MediaBrowser.Controller/Entities/Person.cs +++ b/MediaBrowser.Controller/Entities/Person.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Model.Dto; +using System.Runtime.Serialization; +using MediaBrowser.Model.Dto; using System; using System.Collections.Generic; @@ -15,8 +16,10 @@ namespace MediaBrowser.Controller.Entities UserItemCounts = new Dictionary(); } + [IgnoreDataMember] public ItemByNameCounts ItemCounts { get; set; } + [IgnoreDataMember] public Dictionary UserItemCounts { get; set; } /// diff --git a/MediaBrowser.Controller/Entities/Studio.cs b/MediaBrowser.Controller/Entities/Studio.cs index 8bbf59173f..d3b3566615 100644 --- a/MediaBrowser.Controller/Entities/Studio.cs +++ b/MediaBrowser.Controller/Entities/Studio.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Model.Dto; +using System.Runtime.Serialization; +using MediaBrowser.Model.Dto; using System; using System.Collections.Generic; @@ -24,8 +25,10 @@ namespace MediaBrowser.Controller.Entities return "Studio-" + Name; } + [IgnoreDataMember] public ItemByNameCounts ItemCounts { get; set; } + [IgnoreDataMember] public Dictionary UserItemCounts { get; set; } } } diff --git a/MediaBrowser.Controller/Entities/Year.cs b/MediaBrowser.Controller/Entities/Year.cs index daaebdc855..737feb777c 100644 --- a/MediaBrowser.Controller/Entities/Year.cs +++ b/MediaBrowser.Controller/Entities/Year.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Model.Dto; +using System.Runtime.Serialization; +using MediaBrowser.Model.Dto; using System; using System.Collections.Generic; @@ -15,8 +16,10 @@ namespace MediaBrowser.Controller.Entities UserItemCounts = new Dictionary(); } + [IgnoreDataMember] public ItemByNameCounts ItemCounts { get; set; } + [IgnoreDataMember] public Dictionary UserItemCounts { get; set; } /// diff --git a/MediaBrowser.Model/Querying/ItemSortBy.cs b/MediaBrowser.Model/Querying/ItemSortBy.cs index 65a2162ecc..02307224f9 100644 --- a/MediaBrowser.Model/Querying/ItemSortBy.cs +++ b/MediaBrowser.Model/Querying/ItemSortBy.cs @@ -78,5 +78,8 @@ namespace MediaBrowser.Model.Querying public const string MovieCount = "MovieCount"; public const string SeriesCount = "SeriesCount"; public const string EpisodeCount = "EpisodeCount"; + public const string SongCount = "SongCount"; + public const string AlbumCount = "AlbumCount"; + public const string MusicVideoCount = "MusicVideoCount"; } } diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index ea9f9847be..c92950d702 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -181,6 +181,7 @@ + @@ -191,6 +192,7 @@ + @@ -200,6 +202,7 @@ + diff --git a/MediaBrowser.Server.Implementations/Sorting/AlbumCountComparer.cs b/MediaBrowser.Server.Implementations/Sorting/AlbumCountComparer.cs new file mode 100644 index 0000000000..4680ba9138 --- /dev/null +++ b/MediaBrowser.Server.Implementations/Sorting/AlbumCountComparer.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Library; +using MediaBrowser.Controller.Persistence; +using MediaBrowser.Controller.Sorting; +using MediaBrowser.Model.Querying; + +namespace MediaBrowser.Server.Implementations.Sorting +{ + class AlbumCountComparer : IUserBaseItemComparer + { + /// + /// Gets or sets the user. + /// + /// The user. + public User User { get; set; } + + /// + /// Gets or sets the user manager. + /// + /// The user manager. + public IUserManager UserManager { get; set; } + + /// + /// Gets or sets the user data repository. + /// + /// The user data repository. + public IUserDataRepository UserDataRepository { get; set; } + + /// + /// Compares the specified x. + /// + /// The x. + /// The y. + /// System.Int32. + public int Compare(BaseItem x, BaseItem y) + { + return GetValue(x).CompareTo(GetValue(y)); + } + + /// + /// Gets the date. + /// + /// The x. + /// DateTime. + private int GetValue(BaseItem x) + { + var itemByName = x as IItemByName; + + if (itemByName != null) + { + var counts = itemByName.GetItemByNameCounts(User); + + if (counts != null) + { + return counts.AlbumCount; + } + } + + return 0; + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get { return ItemSortBy.AlbumCount; } + } + } +} diff --git a/MediaBrowser.Server.Implementations/Sorting/MusicVideoCountComparer.cs b/MediaBrowser.Server.Implementations/Sorting/MusicVideoCountComparer.cs new file mode 100644 index 0000000000..9b83d865c4 --- /dev/null +++ b/MediaBrowser.Server.Implementations/Sorting/MusicVideoCountComparer.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Library; +using MediaBrowser.Controller.Persistence; +using MediaBrowser.Controller.Sorting; +using MediaBrowser.Model.Querying; + +namespace MediaBrowser.Server.Implementations.Sorting +{ + class MusicVideoCountComparer : IUserBaseItemComparer + { + /// + /// Gets or sets the user. + /// + /// The user. + public User User { get; set; } + + /// + /// Gets or sets the user manager. + /// + /// The user manager. + public IUserManager UserManager { get; set; } + + /// + /// Gets or sets the user data repository. + /// + /// The user data repository. + public IUserDataRepository UserDataRepository { get; set; } + + /// + /// Compares the specified x. + /// + /// The x. + /// The y. + /// System.Int32. + public int Compare(BaseItem x, BaseItem y) + { + return GetValue(x).CompareTo(GetValue(y)); + } + + /// + /// Gets the date. + /// + /// The x. + /// DateTime. + private int GetValue(BaseItem x) + { + var itemByName = x as IItemByName; + + if (itemByName != null) + { + var counts = itemByName.GetItemByNameCounts(User); + + if (counts != null) + { + return counts.MusicVideoCount; + } + } + + return 0; + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get { return ItemSortBy.MusicVideoCount; } + } + } +} diff --git a/MediaBrowser.Server.Implementations/Sorting/SongCountComparer.cs b/MediaBrowser.Server.Implementations/Sorting/SongCountComparer.cs new file mode 100644 index 0000000000..fe9c95df4c --- /dev/null +++ b/MediaBrowser.Server.Implementations/Sorting/SongCountComparer.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Library; +using MediaBrowser.Controller.Persistence; +using MediaBrowser.Controller.Sorting; +using MediaBrowser.Model.Querying; + +namespace MediaBrowser.Server.Implementations.Sorting +{ + class SongCountComparer : IUserBaseItemComparer + { + /// + /// Gets or sets the user. + /// + /// The user. + public User User { get; set; } + + /// + /// Gets or sets the user manager. + /// + /// The user manager. + public IUserManager UserManager { get; set; } + + /// + /// Gets or sets the user data repository. + /// + /// The user data repository. + public IUserDataRepository UserDataRepository { get; set; } + + /// + /// Compares the specified x. + /// + /// The x. + /// The y. + /// System.Int32. + public int Compare(BaseItem x, BaseItem y) + { + return GetValue(x).CompareTo(GetValue(y)); + } + + /// + /// Gets the date. + /// + /// The x. + /// DateTime. + private int GetValue(BaseItem x) + { + var itemByName = x as IItemByName; + + if (itemByName != null) + { + var counts = itemByName.GetItemByNameCounts(User); + + if (counts != null) + { + return counts.SongCount; + } + } + + return 0; + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get { return ItemSortBy.SongCount; } + } + } +}