From 1ead63b0d1a532cf828a4ed7c5310eef9c255740 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 8 Mar 2014 13:17:05 -0500 Subject: add column sorting to reports --- .../Sorting/GameSystemComparer.cs | 54 ++++++++++++++++++++++ .../Sorting/PlayersComparer.cs | 46 ++++++++++++++++++ .../Sorting/StudioComparer.cs | 30 ++++++++++++ 3 files changed, 130 insertions(+) create mode 100644 MediaBrowser.Server.Implementations/Sorting/GameSystemComparer.cs create mode 100644 MediaBrowser.Server.Implementations/Sorting/PlayersComparer.cs create mode 100644 MediaBrowser.Server.Implementations/Sorting/StudioComparer.cs (limited to 'MediaBrowser.Server.Implementations/Sorting') diff --git a/MediaBrowser.Server.Implementations/Sorting/GameSystemComparer.cs b/MediaBrowser.Server.Implementations/Sorting/GameSystemComparer.cs new file mode 100644 index 000000000..eb83b98e9 --- /dev/null +++ b/MediaBrowser.Server.Implementations/Sorting/GameSystemComparer.cs @@ -0,0 +1,54 @@ +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Sorting; +using MediaBrowser.Model.Querying; +using System; + +namespace MediaBrowser.Server.Implementations.Sorting +{ + public class GameSystemComparer : IBaseItemComparer + { + /// + /// Compares the specified x. + /// + /// The x. + /// The y. + /// System.Int32. + public int Compare(BaseItem x, BaseItem y) + { + return string.Compare(GetValue(x), GetValue(y), StringComparison.CurrentCultureIgnoreCase); + } + + /// + /// Gets the value. + /// + /// The x. + /// System.String. + private string GetValue(BaseItem x) + { + var game = x as Game; + + if (game != null) + { + return game.GameSystem; + } + + var system = x as GameSystem; + + if (system != null) + { + return system.GameSystemName; + } + + return string.Empty; + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get { return ItemSortBy.GameSystem; } + } + } +} diff --git a/MediaBrowser.Server.Implementations/Sorting/PlayersComparer.cs b/MediaBrowser.Server.Implementations/Sorting/PlayersComparer.cs new file mode 100644 index 000000000..5bcd080d7 --- /dev/null +++ b/MediaBrowser.Server.Implementations/Sorting/PlayersComparer.cs @@ -0,0 +1,46 @@ +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Sorting; +using MediaBrowser.Model.Querying; + +namespace MediaBrowser.Server.Implementations.Sorting +{ + public class PlayersComparer : IBaseItemComparer + { + /// + /// 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 value. + /// + /// The x. + /// System.String. + private int GetValue(BaseItem x) + { + var game = x as Game; + + if (game != null) + { + return game.PlayersSupported ?? 0; + } + + return 0; + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get { return ItemSortBy.Players; } + } + } +} diff --git a/MediaBrowser.Server.Implementations/Sorting/StudioComparer.cs b/MediaBrowser.Server.Implementations/Sorting/StudioComparer.cs new file mode 100644 index 000000000..83ab4dfc2 --- /dev/null +++ b/MediaBrowser.Server.Implementations/Sorting/StudioComparer.cs @@ -0,0 +1,30 @@ +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Sorting; +using MediaBrowser.Model.Querying; +using System.Linq; + +namespace MediaBrowser.Server.Implementations.Sorting +{ + public class StudioComparer : IBaseItemComparer + { + /// + /// Compares the specified x. + /// + /// The x. + /// The y. + /// System.Int32. + public int Compare(BaseItem x, BaseItem y) + { + return AlphanumComparator.CompareValues(x.Studios.FirstOrDefault() ?? string.Empty, y.Studios.FirstOrDefault() ?? string.Empty); + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get { return ItemSortBy.Studio; } + } + } +} -- cgit v1.2.3 From d49494476770b3c0a091841bd3bbd44862fb8137 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 9 Mar 2014 18:14:44 -0400 Subject: calculate item by name counts on the fly --- MediaBrowser.Api/BaseApiService.cs | 5 +- .../DefaultTheme/DefaultThemeService.cs | 6 +- MediaBrowser.Api/Playback/BaseStreamingService.cs | 81 +++++++------- MediaBrowser.Api/SearchService.cs | 6 +- MediaBrowser.Api/UserLibrary/ArtistsService.cs | 14 ++- .../UserLibrary/BaseItemsByNameService.cs | 38 +++---- MediaBrowser.Api/UserLibrary/GameGenresService.cs | 9 +- MediaBrowser.Api/UserLibrary/GenresService.cs | 9 +- MediaBrowser.Api/UserLibrary/MusicGenresService.cs | 9 +- MediaBrowser.Api/UserLibrary/PersonsService.cs | 9 +- MediaBrowser.Api/UserLibrary/StudiosService.cs | 9 +- MediaBrowser.Api/UserLibrary/YearsService.cs | 19 +--- .../Channels/ChannelItemInfo.cs | 67 ++++++++++++ MediaBrowser.Controller/Channels/IChannel.cs | 57 ++++++++++ .../Channels/IChannelManager.cs | 12 +++ MediaBrowser.Controller/Dto/IDtoService.cs | 21 ++++ MediaBrowser.Controller/Entities/Audio/Audio.cs | 18 ++++ .../Entities/Audio/MusicArtist.cs | 11 +- .../Entities/Audio/MusicGenre.cs | 18 ++-- MediaBrowser.Controller/Entities/GameGenre.cs | 17 ++- MediaBrowser.Controller/Entities/Genre.cs | 18 ++-- MediaBrowser.Controller/Entities/IItemByName.cs | 38 ++----- MediaBrowser.Controller/Entities/Person.cs | 17 ++- MediaBrowser.Controller/Entities/Studio.cs | 18 ++-- MediaBrowser.Controller/Entities/Year.cs | 29 ++--- MediaBrowser.Controller/Library/ILibraryManager.cs | 13 --- MediaBrowser.Controller/LiveTv/ILiveTvManager.cs | 7 -- MediaBrowser.Controller/LiveTv/LiveTvChannel.cs | 15 +-- .../MediaBrowser.Controller.csproj | 3 + MediaBrowser.Model/Querying/ItemSortBy.cs | 7 -- .../Dto/DtoService.cs | 62 ++++++----- .../Library/LibraryManager.cs | 9 +- .../Library/SearchEngine.cs | 4 +- .../Library/Validators/ArtistsValidator.cs | 45 +------- .../Library/Validators/GameGenresValidator.cs | 62 ++--------- .../Library/Validators/GenresValidator.cs | 62 ++--------- .../Library/Validators/MusicGenresValidator.cs | 73 +++---------- .../Library/Validators/PeoplePostScanTask.cs | 103 ++---------------- .../Library/Validators/PeopleValidator.cs | 6 +- .../Library/Validators/StudiosValidator.cs | 65 ++---------- .../LiveTv/LiveTvManager.cs | 118 ++++++++++++++------- .../MediaBrowser.Server.Implementations.csproj | 7 -- .../Sorting/AlbumCountComparer.cs | 71 ------------- .../Sorting/EpisodeCountComparer.cs | 71 ------------- .../Sorting/MovieCountComparer.cs | 71 ------------- .../Sorting/MusicVideoCountComparer.cs | 71 ------------- .../Sorting/SeriesCountComparer.cs | 71 ------------- .../Sorting/SongCountComparer.cs | 71 ------------- .../Sorting/TrailerCountComparer.cs | 71 ------------- 49 files changed, 517 insertions(+), 1196 deletions(-) create mode 100644 MediaBrowser.Controller/Channels/ChannelItemInfo.cs create mode 100644 MediaBrowser.Controller/Channels/IChannel.cs create mode 100644 MediaBrowser.Controller/Channels/IChannelManager.cs delete mode 100644 MediaBrowser.Server.Implementations/Sorting/AlbumCountComparer.cs delete mode 100644 MediaBrowser.Server.Implementations/Sorting/EpisodeCountComparer.cs delete mode 100644 MediaBrowser.Server.Implementations/Sorting/MovieCountComparer.cs delete mode 100644 MediaBrowser.Server.Implementations/Sorting/MusicVideoCountComparer.cs delete mode 100644 MediaBrowser.Server.Implementations/Sorting/SeriesCountComparer.cs delete mode 100644 MediaBrowser.Server.Implementations/Sorting/SongCountComparer.cs delete mode 100644 MediaBrowser.Server.Implementations/Sorting/TrailerCountComparer.cs (limited to 'MediaBrowser.Server.Implementations/Sorting') diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.cs index 5fba539fe..08686b43a 100644 --- a/MediaBrowser.Api/BaseApiService.cs +++ b/MediaBrowser.Api/BaseApiService.cs @@ -164,7 +164,10 @@ namespace MediaBrowser.Api return name; } - return libraryManager.GetAllArtists() + return libraryManager.RootFolder.RecursiveChildren + .OfType