Fixed: Tags View in UI Slow due to All() Movie Call

pull/5416/head
Qstick 4 years ago
parent a960716cec
commit c16ca46f11

@ -29,6 +29,7 @@ namespace NzbDrone.Core.Movies
Movie FindByPath(string path);
List<string> AllMoviePaths();
List<int> AllMovieTmdbIds();
Dictionary<int, List<int>> AllMovieTags();
List<int> GetRecommendations();
}
@ -290,6 +291,16 @@ namespace NzbDrone.Core.Movies
}
}
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 @@ namespace NzbDrone.Core.Movies
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 @@ namespace NzbDrone.Core.Movies
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 @@ namespace NzbDrone.Core.Tags
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 @@ namespace NzbDrone.Core.Tags
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 @@ namespace NzbDrone.Core.Tags
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 @@ namespace NzbDrone.Core.Tags
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…
Cancel
Save