mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 20:12:41 +02:00
Improve load speeds by being more efficient with config language
This commit is contained in:
parent
37c1b5b28c
commit
708a2e31d5
@ -102,6 +102,7 @@ private List<MovieResource> AllMovie()
|
||||
{
|
||||
var tmdbId = Request.GetIntegerQueryParameter("tmdbId");
|
||||
var moviesResources = new List<MovieResource>();
|
||||
var configLanguage = (Language)_configService.MovieInfoLanguage;
|
||||
|
||||
if (tmdbId > 0)
|
||||
{
|
||||
@ -110,18 +111,18 @@ private List<MovieResource> AllMovie()
|
||||
if (movie != null)
|
||||
{
|
||||
var translations = _movieTranslationService.GetAllTranslationsForMovie(movie.Id);
|
||||
var translation = GetMovieTranslation(translations, movie);
|
||||
var translation = GetMovieTranslation(translations, movie, configLanguage);
|
||||
moviesResources.AddIfNotNull(movie.ToResource(_qualityUpgradableSpecification, translation));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var translations = _movieTranslationService.GetAllTranslationsForLanguage((Language)_configService.MovieInfoLanguage);
|
||||
var translations = _movieTranslationService.GetAllTranslationsForLanguage(configLanguage);
|
||||
var movies = _moviesService.GetAllMovies();
|
||||
|
||||
foreach (var movie in movies)
|
||||
{
|
||||
var translation = GetMovieTranslation(translations, movie);
|
||||
var translation = GetMovieTranslation(translations, movie, configLanguage);
|
||||
moviesResources.Add(movie.ToResource(_qualityUpgradableSpecification, translation));
|
||||
}
|
||||
}
|
||||
@ -145,7 +146,7 @@ protected MovieResource MapToResource(Movie movie)
|
||||
}
|
||||
|
||||
var translations = _movieTranslationService.GetAllTranslationsForMovie(movie.Id);
|
||||
var translation = GetMovieTranslation(translations, movie);
|
||||
var translation = GetMovieTranslation(translations, movie, (Language)_configService.MovieInfoLanguage);
|
||||
|
||||
var resource = movie.ToResource(_qualityUpgradableSpecification, translation);
|
||||
MapCoversToLocal(resource);
|
||||
@ -153,9 +154,9 @@ protected MovieResource MapToResource(Movie movie)
|
||||
return resource;
|
||||
}
|
||||
|
||||
private MovieTranslation GetMovieTranslation(List<MovieTranslation> translations, Movie movie)
|
||||
private MovieTranslation GetMovieTranslation(List<MovieTranslation> translations, Movie movie, Language configLanguage)
|
||||
{
|
||||
if ((Language)_configService.MovieInfoLanguage == Language.Original)
|
||||
if (configLanguage == Language.Original)
|
||||
{
|
||||
return new MovieTranslation
|
||||
{
|
||||
@ -164,7 +165,7 @@ private MovieTranslation GetMovieTranslation(List<MovieTranslation> translations
|
||||
};
|
||||
}
|
||||
|
||||
return translations.FirstOrDefault(t => t.Language == (Language)_configService.MovieInfoLanguage && t.MovieId == movie.Id);
|
||||
return translations.FirstOrDefault(t => t.Language == configLanguage && t.MovieId == movie.Id);
|
||||
}
|
||||
|
||||
private int AddMovie(MovieResource moviesResource)
|
||||
@ -197,7 +198,7 @@ private void UpdateMovie(MovieResource moviesResource)
|
||||
|
||||
var updatedMovie = _moviesService.UpdateMovie(model);
|
||||
var translations = _movieTranslationService.GetAllTranslationsForMovie(movie.Id);
|
||||
var translation = GetMovieTranslation(translations, movie);
|
||||
var translation = GetMovieTranslation(translations, movie, (Language)_configService.MovieInfoLanguage);
|
||||
|
||||
BroadcastResourceChange(ModelAction.Updated, updatedMovie.ToResource(_qualityUpgradableSpecification, translation));
|
||||
}
|
||||
@ -221,7 +222,7 @@ private void MapCoversToLocal(params MovieResource[] movies)
|
||||
public void Handle(MovieImportedEvent message)
|
||||
{
|
||||
var translations = _movieTranslationService.GetAllTranslationsForMovie(message.ImportedMovie.Movie.Id);
|
||||
var translation = GetMovieTranslation(translations, message.ImportedMovie.Movie);
|
||||
var translation = GetMovieTranslation(translations, message.ImportedMovie.Movie, (Language)_configService.MovieInfoLanguage);
|
||||
BroadcastResourceChange(ModelAction.Updated, message.ImportedMovie.Movie.ToResource(_qualityUpgradableSpecification, translation));
|
||||
}
|
||||
|
||||
@ -238,14 +239,14 @@ public void Handle(MovieFileDeletedEvent message)
|
||||
public void Handle(MovieUpdatedEvent message)
|
||||
{
|
||||
var translations = _movieTranslationService.GetAllTranslationsForMovie(message.Movie.Id);
|
||||
var translation = GetMovieTranslation(translations, message.Movie);
|
||||
var translation = GetMovieTranslation(translations, message.Movie, (Language)_configService.MovieInfoLanguage);
|
||||
BroadcastResourceChange(ModelAction.Updated, message.Movie.ToResource(_qualityUpgradableSpecification, translation));
|
||||
}
|
||||
|
||||
public void Handle(MovieEditedEvent message)
|
||||
{
|
||||
var translations = _movieTranslationService.GetAllTranslationsForMovie(message.Movie.Id);
|
||||
var translation = GetMovieTranslation(translations, message.Movie);
|
||||
var translation = GetMovieTranslation(translations, message.Movie, (Language)_configService.MovieInfoLanguage);
|
||||
BroadcastResourceChange(ModelAction.Updated, message.Movie.ToResource(_qualityUpgradableSpecification, translation));
|
||||
}
|
||||
|
||||
@ -260,7 +261,7 @@ public void Handle(MoviesDeletedEvent message)
|
||||
public void Handle(MovieRenamedEvent message)
|
||||
{
|
||||
var translations = _movieTranslationService.GetAllTranslationsForMovie(message.Movie.Id);
|
||||
var translation = GetMovieTranslation(translations, message.Movie);
|
||||
var translation = GetMovieTranslation(translations, message.Movie, (Language)_configService.MovieInfoLanguage);
|
||||
BroadcastResourceChange(ModelAction.Updated, message.Movie.ToResource(_qualityUpgradableSpecification, translation));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user