diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-09-10 14:56:00 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-09-10 14:56:00 -0400 |
| commit | 740a10a4e3f85ffcfd26ec18263d4c78d4b14ecc (patch) | |
| tree | 61462d05ce44c1bb17f48e557b02e14bb480816d /MediaBrowser.Api/UserLibrary/GenresService.cs | |
| parent | d078edfb96fe2dcfebdc34e9189f85b0487ac242 (diff) | |
de-normalize item by name data. create counts during library scan for fast access.
Diffstat (limited to 'MediaBrowser.Api/UserLibrary/GenresService.cs')
| -rw-r--r-- | MediaBrowser.Api/UserLibrary/GenresService.cs | 52 |
1 files changed, 1 insertions, 51 deletions
diff --git a/MediaBrowser.Api/UserLibrary/GenresService.cs b/MediaBrowser.Api/UserLibrary/GenresService.cs index 83405bf52..afec8f799 100644 --- a/MediaBrowser.Api/UserLibrary/GenresService.cs +++ b/MediaBrowser.Api/UserLibrary/GenresService.cs @@ -1,7 +1,5 @@ using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; -using MediaBrowser.Controller.Entities.Movies; -using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Persistence; using MediaBrowser.Model.Dto; @@ -23,25 +21,6 @@ namespace MediaBrowser.Api.UserLibrary { } - [Route("/Genres/{Name}/Counts", "GET")] - [Api(Description = "Gets item counts of library items that a genre appears in")] - public class GetGenreItemCounts : IReturn<ItemByNameCounts> - { - /// <summary> - /// Gets or sets the user id. - /// </summary> - /// <value>The user id.</value> - [ApiMember(Name = "UserId", Description = "User Id", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] - public Guid? UserId { get; set; } - - /// <summary> - /// Gets or sets the name. - /// </summary> - /// <value>The name.</value> - [ApiMember(Name = "Name", Description = "The genre name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] - public string Name { get; set; } - } - /// <summary> /// Class GetGenre /// </summary> @@ -133,7 +112,7 @@ namespace MediaBrowser.Api.UserLibrary return itemsList .SelectMany(i => i.Genres) .Distinct(StringComparer.OrdinalIgnoreCase) - .Select(name => new IbnStub<Genre>(name, () => itemsList.Where(i => i.Genres.Contains(name, StringComparer.OrdinalIgnoreCase)), GetEntity)); + .Select(name => new IbnStub<Genre>(name, GetEntity)); } /// <summary> @@ -145,34 +124,5 @@ namespace MediaBrowser.Api.UserLibrary { return LibraryManager.GetGenre(name); } - - /// <summary> - /// Gets the specified request. - /// </summary> - /// <param name="request">The request.</param> - /// <returns>System.Object.</returns> - public object Get(GetGenreItemCounts request) - { - var name = DeSlugGenreName(request.Name, LibraryManager); - - var items = GetItems(request.UserId).Where(i => i.Genres.Contains(name, StringComparer.OrdinalIgnoreCase)).ToList(); - - var counts = new ItemByNameCounts - { - TotalCount = items.Count, - - TrailerCount = items.OfType<Trailer>().Count(), - - MovieCount = items.OfType<Movie>().Count(), - - SeriesCount = items.OfType<Series>().Count(), - - GameCount = items.OfType<Game>().Count(), - - AdultVideoCount = items.OfType<AdultVideo>().Count() - }; - - return ToOptimizedResult(counts); - } } } |
