From f602542f43885f405310f2f0b9ab20604afc78e5 Mon Sep 17 00:00:00 2001 From: ducklet Date: Tue, 22 Jun 2021 12:14:30 +0200 Subject: [PATCH] fix discarding ratings We want to limit the number of movies, not ratings. By limiting the number of movie IDs before loading all ratings with those movie IDs we can achieve this. --- unwind/db.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unwind/db.py b/unwind/db.py index f609ca2..b81c482 100644 --- a/unwind/db.py +++ b/unwind/db.py @@ -217,6 +217,7 @@ async def find_ratings( SELECT * FROM newest_movies UNION ALL -- using ALL here avoids the reordering of IDs SELECT * FROM unrated_movies + LIMIT :limit_rows )""", ] ) @@ -238,7 +239,6 @@ async def find_ratings( LEFT JOIN {Rating._table} ON {Rating._table}.movie_id={source_table}.movie_id -- LEFT JOIN {User._table} ON {User._table}.id={Rating._table}.user_id LEFT JOIN {Movie._table} ON {Movie._table}.id={source_table}.movie_id - LIMIT :limit_rows """ rows = await shared_connection().fetch_all(bindparams(query, values))