remotes/1693045480750635534/spooky-22
Aevann1 2021-11-15 02:34:13 +02:00
parent 820952819a
commit 9b93e0db79
2 changed files with 12 additions and 3 deletions

View File

@ -24,12 +24,16 @@ SITE_NAME = environ.get("SITE_NAME", "").strip()
def votes2(v, id):
try: id = int(id)
except: abort(400)
votes = g.db.query(Vote.user_id).join(Submission, Vote.submission_id==Submission.id).filter(Vote.vote_type==1, Submission.author_id==id).group_by(Vote.user_id).order_by(func.count(Vote.user_id).desc()).limit(25).all()
votes = g.db.query(Vote.user_id, func.count(Vote.user_id)).join(Submission, Vote.submission_id==Submission.id).filter(Vote.vote_type==1, Submission.author_id==id).group_by(Vote.user_id).order_by(func.count(Vote.user_id).desc()).limit(25).all()
voters=[x[0] for x in votes]
counts=[x[1] for x in votes]
users = g.db.query(User.id, User.username).filter(User.id.in_(voters)).all()
users = [x[1] for x in sorted(users, key=lambda x: voters.index(x[0]))]
return render_template("upvoters.html", users=users)
users2 = []
for idx, user in enumerate(users): users2.append((user, counts[idx]))
return render_template("upvoters.html", v=v, users=users2)
@app.get("/name/<id>/<name>")

View File

@ -1,18 +1,23 @@
{% extends "default.html" %}
{% block content %}
<pre>
</pre>
<table class="table table-striped mb-5">
<thead class="bg-primary text-white">
<tr>
<th style="font-weight: bold">#</th>
<th style="font-weight: bold">Name</th>
<th style="font-weight: bold">Upvotes</th>
</tr>
</thead>
<tbody id="followers-table">
{% for user in users %}
<tr>
<td style="font-weight: bold">{{loop.index}}</td>
<td style="font-weight: bold">{{user}}</td>
<td style="font-weight: bold">{{user[0]}}</td>
<td style="font-weight: bold">{{user[1]}}</td>
</tr>
{% endfor %}
</tbody>