From 740a10a4e3f85ffcfd26ec18263d4c78d4b14ecc Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 10 Sep 2013 14:56:00 -0400 Subject: [PATCH] de-normalize item by name data. create counts during library scan for fast access. --- .../UserLibrary/ArtistsService.cs | 67 +--- .../UserLibrary/BaseItemsByNameService.cs | 25 +- .../UserLibrary/GameGenresService.cs | 42 +-- MediaBrowser.Api/UserLibrary/GenresService.cs | 52 +--- MediaBrowser.Api/UserLibrary/ItemsService.cs | 23 +- .../UserLibrary/MusicGenresService.cs | 46 +-- .../UserLibrary/PersonsService.cs | 72 +---- .../UserLibrary/StudiosService.cs | 59 +--- MediaBrowser.Api/UserLibrary/YearsService.cs | 2 +- .../Entities/Audio/Artist.cs | 16 +- .../Entities/Audio/Audio.cs | 2 +- .../Entities/Audio/IHasAlbumArtist.cs | 5 + .../Entities/Audio/IHasMusicGenres.cs | 9 + .../Entities/Audio/MusicAlbum.cs | 30 +- .../Entities/Audio/MusicGenre.cs | 15 +- MediaBrowser.Controller/Entities/BaseItem.cs | 53 ++++ MediaBrowser.Controller/Entities/GameGenre.cs | 15 +- MediaBrowser.Controller/Entities/Genre.cs | 15 +- .../Entities/IItemByName.cs | 8 +- .../Entities/MusicVideo.cs | 5 +- MediaBrowser.Controller/Entities/Person.cs | 15 +- MediaBrowser.Controller/Entities/Studio.cs | 15 +- MediaBrowser.Controller/Entities/Video.cs | 5 + MediaBrowser.Controller/Entities/Year.cs | 15 +- .../Library/ILibraryManager.cs | 32 ++ .../MediaBrowser.Controller.csproj | 2 + .../Providers/IDynamicInfoProvider.cs | 10 + MediaBrowser.Model/ApiClient/IApiClient.cs | 2 + MediaBrowser.Model/Dto/BaseItemDto.cs | 44 ++- MediaBrowser.Model/Dto/ItemByNameCounts.cs | 4 + .../ImageFromMediaLocationProvider.cs | 74 +---- .../MediaBrowser.Providers.csproj | 4 +- .../Music/ArtistsPostScanTask.cs | 161 ---------- .../Music/MusicAlbumDynamicInfoProvider.cs | 85 ++++++ .../Dto/DtoService.cs | 56 +++- .../HttpServer/NativeWebSocket.cs | 4 + .../Library/LibraryManager.cs | 219 ++++++++------ .../Library/LuceneSearchEngine.cs | 4 +- .../Library/Validators/ArtistsPostScanTask.cs | 38 +++ .../Library/Validators/ArtistsValidator.cs | 285 ++++++++++++++++++ .../Library/Validators/CountHelpers.cs | 155 ++++++++++ .../Validators/GameGenresPostScanTask.cs | 45 +++ .../Library/Validators/GameGenresValidator.cs | 132 ++++++++ .../Library/Validators/GenresPostScanTask.cs | 42 +++ .../Library/Validators/GenresValidator.cs | 135 +++++++++ .../Validators/MusicGenresPostScanTask.cs | 45 +++ .../Validators/MusicGenresValidator.cs | 135 +++++++++ .../Library/Validators/PeoplePostScanTask.cs | 137 +++++++++ .../Library/Validators/StudiosPostScanTask.cs | 45 +++ .../Library/Validators/StudiosValidator.cs | 132 ++++++++ ...MediaBrowser.Server.Implementations.csproj | 13 +- .../Providers/ProviderManager.cs | 6 +- .../ScheduledTasks/ArtistValidationTask.cs | 81 ----- .../Session/SessionManager.cs | 6 +- .../MediaBrowser.ServerApplication.csproj | 7 - .../Resources/Images/mblogoblackfull.png | Bin 59905 -> 0 bytes .../Resources/Images/mblogowhitefull.png | Bin 59826 -> 0 bytes .../Resources/Images/starEmpty.png | Bin 1799 -> 0 bytes .../Resources/Images/starFull.png | Bin 2498 -> 0 bytes .../Resources/Images/starHalf.png | Bin 2020 -> 0 bytes MediaBrowser.WebDashboard/ApiClient.js | 138 --------- MediaBrowser.WebDashboard/packages.config | 2 +- MediaBrowser.sln | 3 + 63 files changed, 1923 insertions(+), 971 deletions(-) create mode 100644 MediaBrowser.Controller/Entities/Audio/IHasMusicGenres.cs create mode 100644 MediaBrowser.Controller/Providers/IDynamicInfoProvider.cs delete mode 100644 MediaBrowser.Providers/Music/ArtistsPostScanTask.cs create mode 100644 MediaBrowser.Providers/Music/MusicAlbumDynamicInfoProvider.cs create mode 100644 MediaBrowser.Server.Implementations/Library/Validators/ArtistsPostScanTask.cs create mode 100644 MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs create mode 100644 MediaBrowser.Server.Implementations/Library/Validators/CountHelpers.cs create mode 100644 MediaBrowser.Server.Implementations/Library/Validators/GameGenresPostScanTask.cs create mode 100644 MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs create mode 100644 MediaBrowser.Server.Implementations/Library/Validators/GenresPostScanTask.cs create mode 100644 MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs create mode 100644 MediaBrowser.Server.Implementations/Library/Validators/MusicGenresPostScanTask.cs create mode 100644 MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs create mode 100644 MediaBrowser.Server.Implementations/Library/Validators/PeoplePostScanTask.cs create mode 100644 MediaBrowser.Server.Implementations/Library/Validators/StudiosPostScanTask.cs create mode 100644 MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs delete mode 100644 MediaBrowser.Server.Implementations/ScheduledTasks/ArtistValidationTask.cs delete mode 100644 MediaBrowser.ServerApplication/Resources/Images/mblogoblackfull.png delete mode 100644 MediaBrowser.ServerApplication/Resources/Images/mblogowhitefull.png delete mode 100644 MediaBrowser.ServerApplication/Resources/Images/starEmpty.png delete mode 100644 MediaBrowser.ServerApplication/Resources/Images/starFull.png delete mode 100644 MediaBrowser.ServerApplication/Resources/Images/starHalf.png diff --git a/MediaBrowser.Api/UserLibrary/ArtistsService.cs b/MediaBrowser.Api/UserLibrary/ArtistsService.cs index 6bc8a2bea..d9db48a30 100644 --- a/MediaBrowser.Api/UserLibrary/ArtistsService.cs +++ b/MediaBrowser.Api/UserLibrary/ArtistsService.cs @@ -22,28 +22,6 @@ namespace MediaBrowser.Api.UserLibrary { } - /// - /// Class GetArtistsItemCounts - /// - [Route("/Artists/{Name}/Counts", "GET")] - [Api(Description = "Gets item counts of library items that an artist appears in")] - public class GetArtistsItemCounts : IReturn - { - /// - /// Gets or sets the user id. - /// - /// The user id. - [ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] - public Guid UserId { get; set; } - - /// - /// Gets or sets the name. - /// - /// The name. - [ApiMember(Name = "Name", Description = "The artist name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] - public string Name { get; set; } - } - [Route("/Artists/{Name}", "GET")] [Api(Description = "Gets an artist, by name")] public class GetArtist : IReturn @@ -114,49 +92,6 @@ namespace MediaBrowser.Api.UserLibrary return await DtoService.GetBaseItemDto(item, fields.ToList()).ConfigureAwait(false); } - /// - /// Gets the specified request. - /// - /// The request. - /// System.Object. - public object Get(GetArtistsItemCounts request) - { - var name = DeSlugArtistName(request.Name, LibraryManager); - - var items = GetItems(request.UserId).Where(i => - { - var song = i as Audio; - - if (song != null) - { - return song.HasArtist(name); - } - - var musicVideo = i as MusicVideo; - - if (musicVideo != null) - { - return musicVideo.HasArtist(name); - } - - return false; - - }).ToList(); - - var counts = new ItemByNameCounts - { - TotalCount = items.Count, - - SongCount = items.OfType