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.
This commit is contained in:
ducklet 2021-06-22 12:14:30 +02:00
parent a6adfefdd8
commit f602542f43

View file

@ -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))