diff --git a/src/Readarr.Api.V1/Author/AuthorController.cs b/src/Readarr.Api.V1/Author/AuthorController.cs index 37711d948..e39cb53ca 100644 --- a/src/Readarr.Api.V1/Author/AuthorController.cs +++ b/src/Readarr.Api.V1/Author/AuthorController.cs @@ -127,7 +127,7 @@ public List AllAuthors() 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 @@ private void FetchAndLinkAuthorStatistics(AuthorResource resource) LinkAuthorStatistics(resource, _authorStatisticsService.AuthorStatistics(resource.Id)); } - private void LinkAuthorStatistics(List resources, List authorStatistics) + private void LinkAuthorStatistics(List resources, Dictionary 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); } }