remotes/1693045480750635534/spooky-22
Aevann1 2021-11-15 02:22:03 +02:00
parent a1db53ec14
commit 6fd16f71b0
2 changed files with 25 additions and 2 deletions

View File

@ -24,8 +24,12 @@ 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, 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()).all()
return(str(votes))
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()).all()
voters=[x[0] 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)
@app.get("/name/<id>/<name>")

View File

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