mirror of
https://github.com/Readarr/Readarr
synced 2026-02-07 07:12:03 +01:00
New: Speed up metadata refresh
This commit is contained in:
parent
8edadbbfa2
commit
7c10f3a74d
1 changed files with 23 additions and 1 deletions
|
|
@ -35,6 +35,7 @@ public class MetadataProfileService : IMetadataProfileService, IHandle<Applicati
|
|||
private readonly IMetadataProfileRepository _profileRepository;
|
||||
private readonly IAuthorService _authorService;
|
||||
private readonly IBookService _bookService;
|
||||
private readonly IEditionService _editionService;
|
||||
private readonly IMediaFileService _mediaFileService;
|
||||
private readonly IImportListFactory _importListFactory;
|
||||
private readonly IRootFolderService _rootFolderService;
|
||||
|
|
@ -44,6 +45,7 @@ public class MetadataProfileService : IMetadataProfileService, IHandle<Applicati
|
|||
public MetadataProfileService(IMetadataProfileRepository profileRepository,
|
||||
IAuthorService authorService,
|
||||
IBookService bookService,
|
||||
IEditionService editionService,
|
||||
IMediaFileService mediaFileService,
|
||||
IImportListFactory importListFactory,
|
||||
IRootFolderService rootFolderService,
|
||||
|
|
@ -53,6 +55,7 @@ public MetadataProfileService(IMetadataProfileRepository profileRepository,
|
|||
_profileRepository = profileRepository;
|
||||
_authorService = authorService;
|
||||
_bookService = bookService;
|
||||
_editionService = editionService;
|
||||
_mediaFileService = mediaFileService;
|
||||
_importListFactory = importListFactory;
|
||||
_rootFolderService = rootFolderService;
|
||||
|
|
@ -112,7 +115,26 @@ public List<Book> 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<Book>();
|
||||
|
||||
var localBooks = new List<Book>();
|
||||
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<Edition>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var localFiles = _mediaFileService.GetFilesByAuthor(dbAuthor?.Id ?? 0);
|
||||
|
||||
return FilterBooks(input.Books.Value, localBooks, localFiles, seriesLinks, profileId);
|
||||
|
|
|
|||
Loading…
Reference in a new issue