From 7c10f3a74d0c953d2224e41f5c69ab2d7d13636b Mon Sep 17 00:00:00 2001 From: ta264 Date: Thu, 2 Sep 2021 21:12:13 +0100 Subject: [PATCH] New: Speed up metadata refresh --- .../Metadata/MetadataProfileService.cs | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Core/Profiles/Metadata/MetadataProfileService.cs b/src/NzbDrone.Core/Profiles/Metadata/MetadataProfileService.cs index 840db3b67..53afee3d1 100644 --- a/src/NzbDrone.Core/Profiles/Metadata/MetadataProfileService.cs +++ b/src/NzbDrone.Core/Profiles/Metadata/MetadataProfileService.cs @@ -35,6 +35,7 @@ public class MetadataProfileService : IMetadataProfileService, IHandle FilterBooks(Author input, int profileId) .ToDictionary(x => x.Key, y => y.ToList()); var dbAuthor = _authorService.FindById(input.ForeignAuthorId); - var localBooks = dbAuthor?.Books.Value ?? new List(); + + var localBooks = new List(); + if (dbAuthor != null) + { + localBooks = _bookService.GetBooksByAuthorMetadataId(dbAuthor.AuthorMetadataId); + var editions = _editionService.GetEditionsByAuthor(dbAuthor.Id).GroupBy(x => x.BookId).ToDictionary(x => x.Key, y => y.ToList()); + + foreach (var book in localBooks) + { + if (editions.TryGetValue(book.Id, out var bookEditions)) + { + book.Editions = bookEditions; + } + else + { + book.Editions = new List(); + } + } + } + var localFiles = _mediaFileService.GetFilesByAuthor(dbAuthor?.Id ?? 0); return FilterBooks(input.Books.Value, localBooks, localFiles, seriesLinks, profileId);