mirror of
https://gitlab.com/SIGBUS/nyaa.git
synced 2025-01-02 15:25:40 +00:00
extensions: limit pagination to max num of pages
This commit is contained in:
parent
6608c99b90
commit
db83989d5d
|
@ -27,6 +27,8 @@ def fix_paginate():
|
||||||
total_query_count = count_query.scalar()
|
total_query_count = count_query.scalar()
|
||||||
else:
|
else:
|
||||||
total_query_count = self.count()
|
total_query_count = self.count()
|
||||||
|
if max_page:
|
||||||
|
total_query_count = min(total_query_count, max_page * per_page)
|
||||||
|
|
||||||
# Grab items on current page
|
# Grab items on current page
|
||||||
items = self.limit(per_page).offset((page - 1) * per_page).all()
|
items = self.limit(per_page).offset((page - 1) * per_page).all()
|
||||||
|
|
|
@ -511,7 +511,6 @@ def search_db(term='', user=None, sort='id', order='desc', category='0_0',
|
||||||
if len(item) >= 2:
|
if len(item) >= 2:
|
||||||
qpc.filter(FullTextSearch(
|
qpc.filter(FullTextSearch(
|
||||||
item, models.TorrentNameSearch, FullTextMode.NATURAL))
|
item, models.TorrentNameSearch, FullTextMode.NATURAL))
|
||||||
|
|
||||||
query, count_query = qpc.items
|
query, count_query = qpc.items
|
||||||
# Sort and order
|
# Sort and order
|
||||||
if sort_column.class_ != models.Torrent:
|
if sort_column.class_ != models.Torrent:
|
||||||
|
|
Loading…
Reference in a new issue