same as prev commit

master
Aevann 2023-05-07 21:35:11 +03:00
parent d3cf9a6116
commit c5d1662566
2 changed files with 7 additions and 5 deletions

View File

@ -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("/@<username>/upvoters")
@limiter.limit(DEFAULT_RATELIMIT)

View File

@ -2,7 +2,7 @@
{% block pagetitle %}{{name2}}{% endblock %}
{% block content %}
<h3 class="my-3" style="text-align: center">{{name2}}</h3>
<h5 class="font-weight-bold text-center mt-3">Total: {{total}}</h5>
<h5 class="font-weight-bold text-center mt-3">Total: {{total_items}}</h5>
<div class="mt-1 overflow-x-auto"><table class="table table-striped mb-5">
<thead class="bg-primary text-white">
<tr>