diff --git a/nyaa/extensions.py b/nyaa/extensions.py index 48d84a5..8ac62ac 100644 --- a/nyaa/extensions.py +++ b/nyaa/extensions.py @@ -27,6 +27,8 @@ def fix_paginate(): total_query_count = count_query.scalar() else: total_query_count = self.count() + if max_page: + total_query_count = min(total_query_count, max_page * per_page) # Grab items on current page items = self.limit(per_page).offset((page - 1) * per_page).all() diff --git a/nyaa/search.py b/nyaa/search.py index 3e04613..aa94e0a 100644 --- a/nyaa/search.py +++ b/nyaa/search.py @@ -511,7 +511,6 @@ def search_db(term='', user=None, sort='id', order='desc', category='0_0', if len(item) >= 2: qpc.filter(FullTextSearch( item, models.TorrentNameSearch, FullTextMode.NATURAL)) - query, count_query = qpc.items # Sort and order if sort_column.class_ != models.Torrent: