New: Improve All Series call by using dictionary for stats iteration
This commit is contained in:
parent
2dbf5b5a71
commit
e792db4d33
|
@ -113,7 +113,7 @@ namespace Sonarr.Api.V3.Series
|
|||
}
|
||||
|
||||
MapCoversToLocal(seriesResources.ToArray());
|
||||
LinkSeriesStatistics(seriesResources, seriesStats);
|
||||
LinkSeriesStatistics(seriesResources, seriesStats.ToDictionary(x => x.SeriesId));
|
||||
PopulateAlternateTitles(seriesResources);
|
||||
seriesResources.ForEach(LinkRootFolderPath);
|
||||
|
||||
|
@ -229,19 +229,16 @@ namespace Sonarr.Api.V3.Series
|
|||
LinkSeriesStatistics(resource, _seriesStatisticsService.SeriesStatistics(resource.Id));
|
||||
}
|
||||
|
||||
private void LinkSeriesStatistics(List<SeriesResource> resources, List<SeriesStatistics> seriesStatistics)
|
||||
private void LinkSeriesStatistics(List<SeriesResource> resources, Dictionary<int, SeriesStatistics> seriesStatistics)
|
||||
{
|
||||
foreach (var series in resources)
|
||||
{
|
||||
var stats = seriesStatistics.SingleOrDefault(ss => ss.SeriesId == series.Id);
|
||||
if (stats == null)
|
||||
if (seriesStatistics.TryGetValue(series.Id, out var stats))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
LinkSeriesStatistics(series, stats);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LinkSeriesStatistics(SeriesResource resource, SeriesStatistics seriesStatistics)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue