From 1ead63b0d1a532cf828a4ed7c5310eef9c255740 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 8 Mar 2014 13:17:05 -0500 Subject: [PATCH] add column sorting to reports --- MediaBrowser.Model/ApiClient/IApiClient.cs | 63 +++++++++++++++++++ MediaBrowser.Model/Querying/ItemSortBy.cs | 3 + ...MediaBrowser.Server.Implementations.csproj | 7 ++- .../Sorting/GameSystemComparer.cs | 54 ++++++++++++++++ .../Sorting/PlayersComparer.cs | 46 ++++++++++++++ .../Sorting/StudioComparer.cs | 30 +++++++++ Nuget/MediaBrowser.Common.Internal.nuspec | 4 +- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +- 9 files changed, 206 insertions(+), 7 deletions(-) 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 diff --git a/MediaBrowser.Model/ApiClient/IApiClient.cs b/MediaBrowser.Model/ApiClient/IApiClient.cs index 2a965114b..a0e527a99 100644 --- a/MediaBrowser.Model/ApiClient/IApiClient.cs +++ b/MediaBrowser.Model/ApiClient/IApiClient.cs @@ -1016,6 +1016,15 @@ namespace MediaBrowser.Model.ApiClient /// Task{QueryResult{ProgramInfoDto}}. Task> GetLiveTvProgramsAsync(ProgramQuery query, CancellationToken cancellationToken); + /// + /// Gets the live tv program asynchronous. + /// + /// The identifier. + /// The user identifier. + /// The cancellation token. + /// Task{ProgramInfoDto}. + Task GetLiveTvProgramAsync(string id, string userId, CancellationToken cancellationToken); + /// /// Gets the recommended live tv programs asynchronous. /// @@ -1023,6 +1032,38 @@ namespace MediaBrowser.Model.ApiClient /// The cancellation token. /// Task{QueryResult{ProgramInfoDto}}. Task> GetRecommendedLiveTvProgramsAsync(RecommendedProgramQuery query, CancellationToken cancellationToken); + + /// + /// Creates the live tv timer asynchronous. + /// + /// The timer. + /// The cancellation token. + /// Task. + Task CreateLiveTvTimerAsync(TimerInfoDto timer, CancellationToken cancellationToken); + + /// + /// Updates the live tv timer asynchronous. + /// + /// The timer. + /// The cancellation token. + /// Task. + Task UpdateLiveTvTimerAsync(TimerInfoDto timer, CancellationToken cancellationToken); + + /// + /// Creates the live tv series timer asynchronous. + /// + /// The timer. + /// The cancellation token. + /// Task. + Task CreateLiveTvSeriesTimerAsync(SeriesTimerInfoDto timer, CancellationToken cancellationToken); + + /// + /// Updates the live tv series timer asynchronous. + /// + /// The timer. + /// The cancellation token. + /// Task. + Task UpdateLiveTvSeriesTimerAsync(SeriesTimerInfoDto timer, CancellationToken cancellationToken); /// /// Gets the live tv timer asynchronous. @@ -1071,5 +1112,27 @@ namespace MediaBrowser.Model.ApiClient /// The cancellation token. /// Task. Task DeleteLiveTvRecordingAsync(string id, CancellationToken cancellationToken); + + /// + /// Gets the default timer information. + /// + /// The cancellation token. + /// Task{SeriesTimerInfoDto}. + Task GetDefaultLiveTvTimerInfo(CancellationToken cancellationToken); + + /// + /// Gets the live tv guide information. + /// + /// The cancellation token. + /// Task{GuideInfo}. + Task GetLiveTvGuideInfo(CancellationToken cancellationToken); + + /// + /// Gets the default timer information. + /// + /// The program identifier. + /// The cancellation token. + /// Task{SeriesTimerInfoDto}. + Task GetDefaultLiveTvTimerInfo(string programId, CancellationToken cancellationToken); } } \ No newline at end of file diff --git a/MediaBrowser.Model/Querying/ItemSortBy.cs b/MediaBrowser.Model/Querying/ItemSortBy.cs index 09b8f0e18..b07db396a 100644 --- a/MediaBrowser.Model/Querying/ItemSortBy.cs +++ b/MediaBrowser.Model/Querying/ItemSortBy.cs @@ -86,5 +86,8 @@ namespace MediaBrowser.Model.Querying public const string VideoBitRate = "VideoBitRate"; public const string AirTime = "AirTime"; public const string Metascore = "Metascore"; + public const string Studio = "Studio"; + public const string Players = "Players"; + public const string GameSystem = "GameSystem"; } } diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index a0df2c23a..78902f0dc 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -225,6 +225,7 @@ + @@ -233,6 +234,7 @@ + @@ -246,6 +248,7 @@ + @@ -376,10 +379,10 @@ swagger-ui\swagger-ui.min.js PreserveNewest - + Always - + Always 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; } + } + } +} diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index 7bd20e7d4..3e548e625 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.336 + 3.0.339 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index f68a42741..5b81a046e 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.336 + 3.0.339 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index 97f4c90a0..bf8bfd157 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.336 + 3.0.339 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - +