Fixed: Disabled List items show up in Discovery

Fixes #5328
This commit is contained in:
Qstick 2020-11-14 22:34:05 -05:00
parent 96852c9f96
commit d5addfa12f
3 changed files with 13 additions and 9 deletions

View File

@ -6,7 +6,7 @@ namespace NzbDrone.Core.ImportLists.ImportListMovies
{
public interface IImportListMovieRepository : IBasicRepository<ImportListMovie>
{
List<ImportListMovie> GetAllForList(int listId);
List<ImportListMovie> GetAllForLists(List<int> listIds);
}
public class ImportListMovieRepository : BasicRepository<ImportListMovie>, IImportListMovieRepository
@ -16,9 +16,9 @@ namespace NzbDrone.Core.ImportLists.ImportListMovies
{
}
public List<ImportListMovie> GetAllForList(int listId)
public List<ImportListMovie> GetAllForLists(List<int> listIds)
{
return Query(x => x.ListId == listId);
return Query(x => listIds.Contains(x.ListId));
}
}
}

View File

@ -9,7 +9,7 @@ namespace NzbDrone.Core.ImportLists.ImportListMovies
public interface IImportListMovieService
{
List<ImportListMovie> GetAllListMovies();
List<ImportListMovie> GetAllForList(int listId);
List<ImportListMovie> GetAllForLists(List<int> listIds);
ImportListMovie AddListMovie(ImportListMovie listMovie);
List<ImportListMovie> AddListMovies(List<ImportListMovie> listMovies);
List<ImportListMovie> SyncMoviesForList(List<ImportListMovie> listMovies, int listId);
@ -43,7 +43,7 @@ namespace NzbDrone.Core.ImportLists.ImportListMovies
public List<ImportListMovie> SyncMoviesForList(List<ImportListMovie> listMovies, int listId)
{
var existingListMovies = GetAllForList(listId);
var existingListMovies = GetAllForLists(new List<int> { listId });
listMovies.ForEach(l => l.Id = existingListMovies.FirstOrDefault(e => e.TmdbId == l.TmdbId)?.Id ?? 0);
@ -59,9 +59,9 @@ namespace NzbDrone.Core.ImportLists.ImportListMovies
return _importListMovieRepository.All().ToList();
}
public List<ImportListMovie> GetAllForList(int listId)
public List<ImportListMovie> GetAllForLists(List<int> listIds)
{
return _importListMovieRepository.GetAllForList(listId).ToList();
return _importListMovieRepository.GetAllForLists(listIds).ToList();
}
public void RemoveListMovie(ImportListMovie listMovie)
@ -76,7 +76,7 @@ namespace NzbDrone.Core.ImportLists.ImportListMovies
public void HandleAsync(ProviderDeletedEvent<IImportList> message)
{
var moviesOnList = _importListMovieRepository.GetAllForList(message.ProviderId);
var moviesOnList = _importListMovieRepository.GetAllForLists(new List<int> { message.ProviderId });
_importListMovieRepository.DeleteMany(moviesOnList);
}
}

View File

@ -2,6 +2,7 @@ using System.Collections.Generic;
using System.Linq;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.ImportLists;
using NzbDrone.Core.ImportLists.ImportExclusions;
using NzbDrone.Core.ImportLists.ImportListMovies;
using NzbDrone.Core.Languages;
@ -20,6 +21,7 @@ namespace Radarr.Api.V3.ImportLists
private readonly IProvideMovieInfo _movieInfo;
private readonly IBuildFileNames _fileNameBuilder;
private readonly IImportListMovieService _listMovieService;
private readonly IImportListFactory _importListFactory;
private readonly IImportExclusionsService _importExclusionService;
private readonly IConfigService _configService;
@ -27,6 +29,7 @@ namespace Radarr.Api.V3.ImportLists
IProvideMovieInfo movieInfo,
IBuildFileNames fileNameBuilder,
IImportListMovieService listMovieService,
IImportListFactory importListFactory,
IImportExclusionsService importExclusionsService,
IConfigService configService)
: base("/importlist/movie")
@ -35,6 +38,7 @@ namespace Radarr.Api.V3.ImportLists
_movieInfo = movieInfo;
_fileNameBuilder = fileNameBuilder;
_listMovieService = listMovieService;
_importListFactory = importListFactory;
_importExclusionService = importExclusionsService;
_configService = configService;
Get("/", x => GetDiscoverMovies());
@ -64,7 +68,7 @@ namespace Radarr.Api.V3.ImportLists
realResults.ForEach(x => x.IsRecommendation = true);
}
var listMovies = MapToResource(_listMovieService.GetAllListMovies(), movieLanguge).ToList();
var listMovies = MapToResource(_listMovieService.GetAllForLists(_importListFactory.Enabled().Select(x => x.Definition.Id).ToList()), movieLanguge).ToList();
realResults.AddRange(listMovies);