From c5d1662566d9d343c978ace313f70ad91abc609c Mon Sep 17 00:00:00 2001 From: Aevann Date: Sun, 7 May 2023 21:35:11 +0300 Subject: [PATCH] same as prev commit --- files/routes/users.py | 10 ++++++---- files/templates/userpage/voters.html | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/files/routes/users.py b/files/routes/users.py index bd77b7db0..6a9d84c19 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -269,7 +269,7 @@ def all_upvoters_downvoters(v:User, username:str, vote_dir:int, is_who_simps_hat votes = g.db.query(Vote.user_id, func.count(Vote.user_id)).join(Submission).filter(Submission.ghost == False, Submission.is_banned == False, Submission.deleted_utc == 0, Vote.vote_type==vote_dir, Submission.author_id==id).group_by(Vote.user_id).order_by(func.count(Vote.user_id).desc()).all() votes2 = g.db.query(CommentVote.user_id, func.count(CommentVote.user_id)).join(Comment).filter(Comment.ghost == False, Comment.is_banned == False, Comment.deleted_utc == 0, CommentVote.vote_type==vote_dir, Comment.author_id==id).group_by(CommentVote.user_id).order_by(func.count(CommentVote.user_id).desc()).all() votes = Counter(dict(votes)) + Counter(dict(votes2)) - total = sum(votes.values()) + total_items = sum(votes.values()) users = g.db.query(User).filter(User.id.in_(votes.keys())) users2 = [(user, votes[user.id]) for user in users.all()] @@ -282,16 +282,18 @@ def all_upvoters_downvoters(v:User, username:str, vote_dir:int, is_who_simps_hat except: pos = (len(users)+1, 0) received_given = 'given' if is_who_simps_hates else 'received' - if total == 1: vote_str = vote_str[:-1] # we want to unpluralize if only 1 vote - total = f'{total} {vote_str} {received_given}' + if total_items == 1: vote_str = vote_str[:-1] # we want to unpluralize if only 1 vote + total_items = f'{total_items} {vote_str} {received_given}' name2 = f'Who @{username} {simps_haters}' if is_who_simps_hates else f"@{username}'s {simps_haters}" page = get_page() + total = len(users) + users = users[PAGE_SIZE * (page-1):PAGE_SIZE] - return render_template("userpage/voters.html", v=v, users=users, pos=pos, name=vote_name, name2=name2, page=page, total=total) + return render_template("userpage/voters.html", v=v, users=users, pos=pos, name=vote_name, name2=name2, page=page, total_items=total_items, total=total) @app.get("/@/upvoters") @limiter.limit(DEFAULT_RATELIMIT) diff --git a/files/templates/userpage/voters.html b/files/templates/userpage/voters.html index fbb0affaf..f9e346131 100644 --- a/files/templates/userpage/voters.html +++ b/files/templates/userpage/voters.html @@ -2,7 +2,7 @@ {% block pagetitle %}{{name2}}{% endblock %} {% block content %}

{{name2}}

-
Total: {{total}}
+
Total: {{total_items}}