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.Api/UserLibrary/ItemsService.cs | |
| parent | 1496991096c4db9f69bc572aeefc8099ca0f0c01 (diff) | |
improved performance of item counts
Diffstat (limited to 'MediaBrowser.Api/UserLibrary/ItemsService.cs')
| -rw-r--r-- | MediaBrowser.Api/UserLibrary/ItemsService.cs | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index 1cf8fda20..80246a5d8 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -121,7 +121,7 @@ namespace MediaBrowser.Api.UserLibrary [ApiMember(Name = "AlbumArtistStartsWithOrGreater", Description = "Optional filter by items whose album artist is sorted equally or greater than a given input string.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] public string AlbumArtistStartsWithOrGreater { get; set; } - + /// <summary> /// Gets or sets the air days. /// </summary> @@ -161,8 +161,14 @@ namespace MediaBrowser.Api.UserLibrary [ApiMember(Name = "AdjacentTo", Description = "Optional. Return items that are siblings of a supplied item.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] public string AdjacentTo { get; set; } - [ApiMember(Name = "MinIndexNumber", Description = "Optional filter index number.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] + [ApiMember(Name = "MinIndexNumber", Description = "Optional filter by minimum index number.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] public int? MinIndexNumber { get; set; } + + [ApiMember(Name = "HasParentalRating", Description = "Optional filter by items that have or do not have a parental rating", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] + public bool? HasParentalRating { get; set; } + + [ApiMember(Name = "IsHD", Description = "Optional filter by items that are HD or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] + public bool? IsHD { get; set; } } /// <summary> @@ -481,7 +487,12 @@ namespace MediaBrowser.Api.UserLibrary { items = items.Where(i => { - var rating = i.CustomRating ?? i.OfficialRating; + var rating = i.CustomRating; + + if (string.IsNullOrEmpty(rating)) + { + rating = i.OfficialRating; + } if (string.IsNullOrEmpty(rating)) { @@ -504,7 +515,12 @@ namespace MediaBrowser.Api.UserLibrary { items = items.Where(i => { - var rating = i.CustomRating ?? i.OfficialRating; + var rating = i.CustomRating; + + if (string.IsNullOrEmpty(rating)) + { + rating = i.OfficialRating; + } if (string.IsNullOrEmpty(rating)) { @@ -669,6 +685,31 @@ namespace MediaBrowser.Api.UserLibrary }); } + if (request.HasParentalRating.HasValue) + { + items = items.Where(i => + { + var rating = i.CustomRating; + + if (string.IsNullOrEmpty(rating)) + { + rating = i.OfficialRating; + } + + if (request.HasParentalRating.Value) + { + return !string.IsNullOrEmpty(rating); + } + + return string.IsNullOrEmpty(rating); + }); + } + + if (request.IsHD.HasValue) + { + items = items.OfType<Video>().Where(i => i.IsHd == request.IsHD.Value); + } + return items; } |
