add total counter for simps, haters, simping for, hates

master
Aevann1 2022-06-25 01:22:20 +02:00
parent 55ebd98f40
commit d59a80245d
2 changed files with 26 additions and 5 deletions

View File

@ -283,6 +283,8 @@ def upvoters(v, username):
votes = Counter(dict(votes)) + Counter(dict(votes2))
total = sum(votes.values())
users = g.db.query(User).filter(User.id.in_(votes.keys())).all()
users2 = []
for user in users: users2.append((user, votes[user.id]))
@ -294,7 +296,10 @@ def upvoters(v, username):
pos = (pos+1, users[pos][1])
except: pos = (len(users)+1, 0)
return render_template("voters.html", v=v, users=users[:25], pos=pos, name='Up', name2=f'@{username} biggest simps')
if total == 1: total=f'{total} upvote received'
else: total=f'{total} upvotes received'
return render_template("voters.html", v=v, users=users[:25], pos=pos, name='Up', name2=f'@{username} biggest simps', total=total)
@ -309,6 +314,8 @@ def downvoters(v, username):
votes = Counter(dict(votes)) + Counter(dict(votes2))
total = sum(votes.values())
users = g.db.query(User).filter(User.id.in_(votes.keys())).all()
users2 = []
for user in users: users2.append((user, votes[user.id]))
@ -320,7 +327,10 @@ def downvoters(v, username):
pos = (pos+1, users[pos][1])
except: pos = (len(users)+1, 0)
return render_template("voters.html", v=v, users=users[:25], pos=pos, name='Down', name2=f'@{username} biggest haters')
if total == 1: total=f'{total} downvote received'
else: total=f'{total} downvotes received'
return render_template("voters.html", v=v, users=users[:25], pos=pos, name='Down', name2=f'@{username} biggest haters', total=total)
@app.get("/@<username>/upvoting")
@auth_required
@ -333,6 +343,8 @@ def upvoting(v, username):
votes = Counter(dict(votes)) + Counter(dict(votes2))
total = sum(votes.values())
users = g.db.query(User).filter(User.id.in_(votes.keys())).all()
users2 = []
for user in users: users2.append((user, votes[user.id]))
@ -344,7 +356,10 @@ def upvoting(v, username):
pos = (pos+1, users[pos][1])
except: pos = (len(users)+1, 0)
return render_template("voters.html", v=v, users=users[:25], pos=pos, name='Up', name2=f'Who @{username} simps for')
if total == 1: total=f'{total} upvote given'
else: total=f'{total} upvotes given'
return render_template("voters.html", v=v, users=users[:25], pos=pos, name='Up', name2=f'Who @{username} simps for', total=total)
@app.get("/@<username>/downvoting")
@auth_required
@ -357,6 +372,8 @@ def downvoting(v, username):
votes = Counter(dict(votes)) + Counter(dict(votes2))
total = sum(votes.values())
users = g.db.query(User).filter(User.id.in_(votes.keys())).all()
users2 = []
for user in users: users2.append((user, votes[user.id]))
@ -368,7 +385,10 @@ def downvoting(v, username):
pos = (pos+1, users[pos][1])
except: pos = (len(users)+1, 0)
return render_template("voters.html", v=v, users=users[:25], pos=pos, name='Down', name2=f'Who @{username} hates')
if total == 1: total=f'{total} downvote given'
else: total=f'{total} downvotes given'
return render_template("voters.html", v=v, users=users[:25], pos=pos, name='Down', name2=f'Who @{username} hates', total=total)

View File

@ -4,7 +4,8 @@
</pre>
<h5 style="text-align: center">{{name2}}</h5>
<h3 style="text-align: center">{{name2}}</h3>
<h5 class="font-weight-bold text-center mt-3">Total: {{total}}</h5>
<pre></pre>
<div class="overflow-x-auto"><table class="table table-striped mb-5">
<thead class="bg-primary text-white">