From eff429223b2434e40e151c507ae19c325fa57db6 Mon Sep 17 00:00:00 2001 From: Aevann Date: Fri, 5 May 2023 04:06:25 +0300 Subject: [PATCH] use new pagination system in /transfers --- files/routes/static.py | 9 ++++----- files/templates/transfers.html | 19 +------------------ 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/files/routes/static.py b/files/routes/static.py index 90408e99fa..e8a446af5a 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -370,7 +370,7 @@ def transfers_id(id, v): if not transfer: abort(404) - return render_template("transfers.html", v=v, page=1, comments=[transfer], standalone=True, next_exists=False) + return render_template("transfers.html", v=v, page=1, comments=[transfer], standalone=True, next_exists=1) @app.get("/transfers") @limiter.limit(DEFAULT_RATELIMIT) @@ -378,14 +378,13 @@ def transfers_id(id, v): @auth_required def transfers(v:User): - comments = g.db.query(Comment).filter(Comment.author_id == AUTOJANNY_ID, Comment.parent_submission == None, Comment.body_html.like("% has transferred %")).order_by(Comment.id.desc()) + comments = g.db.query(Comment).filter(Comment.author_id == AUTOJANNY_ID, Comment.parent_submission == None, Comment.body_html.like("% has transferred %")) try: page = max(int(request.values.get("page", 1)), 1) except: page = 1 - comments = comments.offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE + 1).all() - next_exists = len(comments) > PAGE_SIZE - comments = comments[:PAGE_SIZE] + next_exists = comments.count() + comments = comments.order_by(Comment.id.desc()).offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE).all() if v.client: return {"data": [x.json(g.db) for x in comments]} diff --git a/files/templates/transfers.html b/files/templates/transfers.html index 46b88f6304..e4a408a028 100644 --- a/files/templates/transfers.html +++ b/files/templates/transfers.html @@ -13,24 +13,7 @@ {% endblock %} {% block pagenav %} - +{% include "pagination.html" %}
Link copied to clipboard