mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 12:02:35 +02:00
Fixed: Tags View in UI Slow due to All() Movie Call
This commit is contained in:
parent
a960716cec
commit
c16ca46f11
@ -29,6 +29,7 @@ public interface IMovieRepository : IBasicRepository<Movie>
|
||||
Movie FindByPath(string path);
|
||||
List<string> AllMoviePaths();
|
||||
List<int> AllMovieTmdbIds();
|
||||
Dictionary<int, List<int>> AllMovieTags();
|
||||
List<int> GetRecommendations();
|
||||
}
|
||||
|
||||
@ -290,6 +291,16 @@ public List<int> AllMovieTmdbIds()
|
||||
}
|
||||
}
|
||||
|
||||
public Dictionary<int, List<int>> AllMovieTags()
|
||||
{
|
||||
using (var conn = _database.OpenConnection())
|
||||
{
|
||||
string strSql = "SELECT Id AS [Key], Tags AS [Value] FROM Movies";
|
||||
var tags = conn.Query<KeyValuePair<int, List<int>>>(strSql).ToDictionary(x => x.Key, x => x.Value);
|
||||
return tags;
|
||||
}
|
||||
}
|
||||
|
||||
public List<int> GetRecommendations()
|
||||
{
|
||||
var recommendations = new List<List<int>>();
|
||||
|
@ -41,7 +41,7 @@ public interface IMovieService
|
||||
void DeleteMovie(int movieId, bool deleteFiles, bool addExclusion = false);
|
||||
void DeleteMovies(List<int> movieIds, bool deleteFiles, bool addExclusion = false);
|
||||
List<Movie> GetAllMovies();
|
||||
List<Movie> AllForTag(int tagId);
|
||||
Dictionary<int, List<int>> AllMovieTags();
|
||||
Movie UpdateMovie(Movie movie);
|
||||
List<Movie> UpdateMovie(List<Movie> movie, bool useExistingRelativeFolder);
|
||||
List<Movie> FilterExistingMovies(List<Movie> movies);
|
||||
@ -227,10 +227,9 @@ public List<Movie> GetAllMovies()
|
||||
return _movieRepository.All().ToList();
|
||||
}
|
||||
|
||||
public List<Movie> AllForTag(int tagId)
|
||||
public Dictionary<int, List<int>> AllMovieTags()
|
||||
{
|
||||
return GetAllMovies().Where(s => s.Tags.Contains(tagId))
|
||||
.ToList();
|
||||
return _movieRepository.AllMovieTags();
|
||||
}
|
||||
|
||||
public Movie UpdateMovie(Movie movie)
|
||||
|
@ -79,7 +79,7 @@ public TagDetails Details(int tagId)
|
||||
var importLists = _importListFactory.AllForTag(tagId);
|
||||
var notifications = _notificationFactory.AllForTag(tagId);
|
||||
var restrictions = _restrictionService.AllForTag(tagId);
|
||||
var movies = _movieService.AllForTag(tagId);
|
||||
var movies = _movieService.AllMovieTags().Where(x => x.Value.Contains(tagId)).Select(x => x.Key).ToList();
|
||||
|
||||
return new TagDetails
|
||||
{
|
||||
@ -89,7 +89,7 @@ public TagDetails Details(int tagId)
|
||||
ImportListIds = importLists.Select(c => c.Id).ToList(),
|
||||
NotificationIds = notifications.Select(c => c.Id).ToList(),
|
||||
RestrictionIds = restrictions.Select(c => c.Id).ToList(),
|
||||
MovieIds = movies.Select(c => c.Id).ToList()
|
||||
MovieIds = movies
|
||||
};
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ public List<TagDetails> Details()
|
||||
var importLists = _importListFactory.All();
|
||||
var notifications = _notificationFactory.All();
|
||||
var restrictions = _restrictionService.All();
|
||||
var movies = _movieService.GetAllMovies();
|
||||
var movies = _movieService.AllMovieTags();
|
||||
|
||||
var details = new List<TagDetails>();
|
||||
|
||||
@ -114,7 +114,7 @@ public List<TagDetails> Details()
|
||||
ImportListIds = importLists.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList(),
|
||||
NotificationIds = notifications.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList(),
|
||||
RestrictionIds = restrictions.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList(),
|
||||
MovieIds = movies.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList()
|
||||
MovieIds = movies.Where(c => c.Value.Contains(tag.Id)).Select(c => c.Key).ToList()
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user