mirror of
https://github.com/fergalmoran/Readarr.git
synced 2026-02-09 01:16:49 +00:00
New: Improve All Authors call by using dictionary for stats iteration
(cherry picked from commit e792db4d3355fedd3ea9e35b3f5e1e30394d9ee3) Closes #3230
This commit is contained in:
@@ -127,7 +127,7 @@ namespace Readarr.Api.V1.Author
|
||||
|
||||
MapCoversToLocal(authorResources.ToArray());
|
||||
LinkNextPreviousBooks(authorResources.ToArray());
|
||||
LinkAuthorStatistics(authorResources, authorStats);
|
||||
LinkAuthorStatistics(authorResources, authorStats.ToDictionary(x => x.AuthorId));
|
||||
LinkRootFolderPath(authorResources.ToArray());
|
||||
|
||||
return authorResources;
|
||||
@@ -200,17 +200,14 @@ namespace Readarr.Api.V1.Author
|
||||
LinkAuthorStatistics(resource, _authorStatisticsService.AuthorStatistics(resource.Id));
|
||||
}
|
||||
|
||||
private void LinkAuthorStatistics(List<AuthorResource> resources, List<AuthorStatistics> authorStatistics)
|
||||
private void LinkAuthorStatistics(List<AuthorResource> resources, Dictionary<int, AuthorStatistics> authorStatistics)
|
||||
{
|
||||
foreach (var author in resources)
|
||||
{
|
||||
var stats = authorStatistics.SingleOrDefault(ss => ss.AuthorId == author.Id);
|
||||
if (stats == null)
|
||||
if (authorStatistics.TryGetValue(author.Id, out var stats))
|
||||
{
|
||||
continue;
|
||||
LinkAuthorStatistics(author, stats);
|
||||
}
|
||||
|
||||
LinkAuthorStatistics(author, stats);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user