From 3759625386d717329dcc02f65ca971d394c7f657 Mon Sep 17 00:00:00 2001 From: bakerboy448 <55419169+bakerboy448@users.noreply.github.com> Date: Mon, 21 Dec 2020 15:28:35 -0600 Subject: [PATCH] New: Improved Discover recommendations New: Movies existing in Library no longer show as a Discover Recommendations --- src/NzbDrone.Core/Movies/MovieRepository.cs | 15 +++++++-------- src/NzbDrone.Core/Movies/MovieService.cs | 4 ++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/NzbDrone.Core/Movies/MovieRepository.cs b/src/NzbDrone.Core/Movies/MovieRepository.cs index 3c2d2927a..af1e17103 100644 --- a/src/NzbDrone.Core/Movies/MovieRepository.cs +++ b/src/NzbDrone.Core/Movies/MovieRepository.cs @@ -313,19 +313,18 @@ namespace NzbDrone.Core.Movies public List GetRecommendations() { - var recommendations = new List>(); - var tmdbIds = AllMovieTmdbIds(); + var recommendations = new List(); using (var conn = _database.OpenConnection()) { - recommendations = conn.Query>("SELECT Recommendations FROM Movies ORDER BY id DESC LIMIT 100").ToList(); + recommendations = conn.Query(@" + SELECT Rec FROM + (SELECT CAST(j.value AS INT) AS Rec FROM Movies CROSS JOIN json_each(Movies.Recommendations) AS j + WHERE Rec NOT IN (SELECT TmdbId FROM Movies)) + GROUP BY Rec ORDER BY count(*) DESC LIMIT 100;").ToList(); } - return recommendations.SelectMany(x => x) - .Where(r => !tmdbIds.Any(m => m == r)) - .Distinct() - .Take(100) - .ToList(); + return recommendations; } } } diff --git a/src/NzbDrone.Core/Movies/MovieService.cs b/src/NzbDrone.Core/Movies/MovieService.cs index 9dfedaaa1..07d5d5fca 100644 --- a/src/NzbDrone.Core/Movies/MovieService.cs +++ b/src/NzbDrone.Core/Movies/MovieService.cs @@ -286,7 +286,7 @@ namespace NzbDrone.Core.Movies public void SetFileId(Movie movie, MovieFile movieFile) { _movieRepository.SetFileId(movieFile.Id, movie.Id); - _logger.Info("Linking [{0}] > [{1}]", movieFile.RelativePath, movie); + _logger.Info("Assigning file [{0}] to movie [{1}]", movieFile.RelativePath, movie); } public List GetMoviesByFileId(int fileId) @@ -386,7 +386,7 @@ namespace NzbDrone.Core.Movies _movieRepository.Update(movie); //_movieRepository.SetFileId(message.MovieFile.Id, message.MovieFile.Movie.Value.Id); - _logger.Info("Linking [{0}] > [{1}]", message.MovieFile.RelativePath, message.MovieFile.Movie); + _logger.Info("Assigning file [{0}] to movie [{1}]", message.MovieFile.RelativePath, message.MovieFile.Movie); } public void Handle(MovieFileDeletedEvent message)