mirror of
https://github.com/Radarr/Radarr
synced 2025-02-24 07:10:57 +00:00
Fix regression in collections endpoint speed
This commit is contained in:
parent
3244282a83
commit
cff54d76b9
1 changed files with 12 additions and 4 deletions
|
@ -1,4 +1,6 @@
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
|
@ -60,6 +62,7 @@ protected override CollectionResource GetResourceById(int id)
|
||||||
public List<CollectionResource> GetCollections(int? tmdbId)
|
public List<CollectionResource> GetCollections(int? tmdbId)
|
||||||
{
|
{
|
||||||
var collectionResources = new List<CollectionResource>();
|
var collectionResources = new List<CollectionResource>();
|
||||||
|
var coverFileInfos = _coverMapper.GetCoverFileInfos();
|
||||||
|
|
||||||
if (tmdbId.HasValue)
|
if (tmdbId.HasValue)
|
||||||
{
|
{
|
||||||
|
@ -72,7 +75,7 @@ public List<CollectionResource> GetCollections(int? tmdbId)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
collectionResources = MapToResource(_collectionService.GetAllCollections()).ToList();
|
collectionResources = MapToResource(_collectionService.GetAllCollections(), coverFileInfos).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
return collectionResources;
|
return collectionResources;
|
||||||
|
@ -134,7 +137,7 @@ public ActionResult UpdateCollections(CollectionUpdateResource resource)
|
||||||
return Accepted(updated);
|
return Accepted(updated);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<CollectionResource> MapToResource(List<MovieCollection> collections)
|
private IEnumerable<CollectionResource> MapToResource(List<MovieCollection> collections, Dictionary<string, FileInfo> coverFileInfos)
|
||||||
{
|
{
|
||||||
// Avoid calling for naming spec on every movie in filenamebuilder
|
// Avoid calling for naming spec on every movie in filenamebuilder
|
||||||
var namingConfig = _namingService.GetConfig();
|
var namingConfig = _namingService.GetConfig();
|
||||||
|
@ -150,8 +153,6 @@ private IEnumerable<CollectionResource> MapToResource(List<MovieCollection> coll
|
||||||
var movieResource = movie.ToResource();
|
var movieResource = movie.ToResource();
|
||||||
movieResource.Folder = _fileNameBuilder.GetMovieFolder(new Movie { MovieMetadata = movie }, namingConfig);
|
movieResource.Folder = _fileNameBuilder.GetMovieFolder(new Movie { MovieMetadata = movie }, namingConfig);
|
||||||
|
|
||||||
_coverMapper.ConvertToLocalUrls(0, movieResource.Images);
|
|
||||||
|
|
||||||
if (!existingMoviesTmdbIds.Contains(movie.TmdbId))
|
if (!existingMoviesTmdbIds.Contains(movie.TmdbId))
|
||||||
{
|
{
|
||||||
resource.MissingMovies++;
|
resource.MissingMovies++;
|
||||||
|
@ -160,6 +161,8 @@ private IEnumerable<CollectionResource> MapToResource(List<MovieCollection> coll
|
||||||
resource.Movies.Add(movieResource);
|
resource.Movies.Add(movieResource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MapCoversToLocal(resource.Movies, coverFileInfos);
|
||||||
|
|
||||||
yield return resource;
|
yield return resource;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -188,6 +191,11 @@ private CollectionResource MapToResource(MovieCollection collection)
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void MapCoversToLocal(IEnumerable<CollectionMovieResource> movies, Dictionary<string, FileInfo> coverFileInfos)
|
||||||
|
{
|
||||||
|
_coverMapper.ConvertToLocalUrls(movies.Select(x => Tuple.Create(0, x.Images.AsEnumerable())), coverFileInfos);
|
||||||
|
}
|
||||||
|
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public void Handle(CollectionAddedEvent message)
|
public void Handle(CollectionAddedEvent message)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue