From 740a10a4e3f85ffcfd26ec18263d4c78d4b14ecc Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 10 Sep 2013 14:56:00 -0400 Subject: de-normalize item by name data. create counts during library scan for fast access. --- MediaBrowser.Api/UserLibrary/GenresService.cs | 52 +-------------------------- 1 file changed, 1 insertion(+), 51 deletions(-) (limited to 'MediaBrowser.Api/UserLibrary/GenresService.cs') 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 - { - /// - /// Gets or sets the user id. - /// - /// The user id. - [ApiMember(Name = "UserId", Description = "User Id", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] - public Guid? UserId { get; set; } - - /// - /// Gets or sets the name. - /// - /// The name. - [ApiMember(Name = "Name", Description = "The genre name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] - public string Name { get; set; } - } - /// /// Class GetGenre /// @@ -133,7 +112,7 @@ namespace MediaBrowser.Api.UserLibrary return itemsList .SelectMany(i => i.Genres) .Distinct(StringComparer.OrdinalIgnoreCase) - .Select(name => new IbnStub(name, () => itemsList.Where(i => i.Genres.Contains(name, StringComparer.OrdinalIgnoreCase)), GetEntity)); + .Select(name => new IbnStub(name, GetEntity)); } /// @@ -145,34 +124,5 @@ namespace MediaBrowser.Api.UserLibrary { return LibraryManager.GetGenre(name); } - - /// - /// Gets the specified request. - /// - /// The request. - /// System.Object. - 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().Count(), - - MovieCount = items.OfType().Count(), - - SeriesCount = items.OfType().Count(), - - GameCount = items.OfType().Count(), - - AdultVideoCount = items.OfType().Count() - }; - - return ToOptimizedResult(counts); - } } } -- cgit v1.2.3