mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-23 14:55:20 -07:00
Fixed: Lists are fetched much more efficiently. (Up to 40x loading time improvement with large lists!)
This commit is contained in:
parent
fb4f510909
commit
964c18b236
3 changed files with 20 additions and 2 deletions
|
@ -9,7 +9,7 @@ namespace NzbDrone.Api.NetImport
|
||||||
{
|
{
|
||||||
public NetImportModule(NetImportFactory netImportFactory) : base(netImportFactory, "netimport")
|
public NetImportModule(NetImportFactory netImportFactory) : base(netImportFactory, "netimport")
|
||||||
{
|
{
|
||||||
PostValidator.RuleFor(c => c.RootFolderPath).NotNull();
|
PostValidator.RuleFor(c => c.RootFolderPath).IsValidPath();
|
||||||
PostValidator.RuleFor(c => c.MinimumAvailability).NotNull();
|
PostValidator.RuleFor(c => c.MinimumAvailability).NotNull();
|
||||||
PostValidator.RuleFor(c => c.ProfileId).NotNull();
|
PostValidator.RuleFor(c => c.ProfileId).NotNull();
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ namespace NzbDrone.Core.NetImport
|
||||||
{
|
{
|
||||||
var movies = MovieListSearch(listId, onlyEnableAuto);
|
var movies = MovieListSearch(listId, onlyEnableAuto);
|
||||||
|
|
||||||
return movies.Where(x => !_movieService.MovieExists(x)).ToList();
|
return _movieService.FilterExistingMovies(movies);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Movie> MovieListSearch(int listId, bool onlyEnableAuto = false)
|
public List<Movie> MovieListSearch(int listId, bool onlyEnableAuto = false)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -39,6 +40,7 @@ namespace NzbDrone.Core.Tv
|
||||||
List<Movie> GetAllMovies();
|
List<Movie> GetAllMovies();
|
||||||
Movie UpdateMovie(Movie movie);
|
Movie UpdateMovie(Movie movie);
|
||||||
List<Movie> UpdateMovie(List<Movie> movie);
|
List<Movie> UpdateMovie(List<Movie> movie);
|
||||||
|
List<Movie> FilterExistingMovies(List<Movie> movies);
|
||||||
bool MoviePathExists(string folder);
|
bool MoviePathExists(string folder);
|
||||||
void RemoveAddOptions(Movie movie);
|
void RemoveAddOptions(Movie movie);
|
||||||
List<Movie> MoviesWithFiles(int movieId);
|
List<Movie> MoviesWithFiles(int movieId);
|
||||||
|
@ -444,5 +446,21 @@ namespace NzbDrone.Core.Tv
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Movie> FilterExistingMovies(List<Movie> movies)
|
||||||
|
{
|
||||||
|
var allMovies = GetAllMovies();
|
||||||
|
|
||||||
|
var withTmdbid = movies.Where(m => m.TmdbId != 0).ToList();
|
||||||
|
var withoutTmdbid = movies.Where(m => m.TmdbId == 0).ToList();
|
||||||
|
var withImdbid = withoutTmdbid.Where(m => m.ImdbId.IsNotNullOrWhiteSpace());
|
||||||
|
var rest = withoutTmdbid.Where(m => m.ImdbId.IsNullOrWhiteSpace());
|
||||||
|
|
||||||
|
var ret = withTmdbid.ExceptBy(m => m.TmdbId, allMovies, m => m.TmdbId, EqualityComparer<int>.Default)
|
||||||
|
.Union(withImdbid.ExceptBy(m => m.ImdbId, allMovies, m => m.ImdbId, EqualityComparer<string>.Default))
|
||||||
|
.Union(rest.ExceptBy(m => m.Title.CleanSeriesTitle(), allMovies, m => m.CleanTitle, EqualityComparer<string>.Default)).ToList();
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue