sfdsdf
This commit is contained in:
parent
9355674ddc
commit
20270afebf
2 changed files with 12 additions and 3 deletions
|
@ -24,12 +24,16 @@ SITE_NAME = environ.get("SITE_NAME", "").strip()
|
||||||
def votes2(v, id):
|
def votes2(v, id):
|
||||||
try: id = int(id)
|
try: id = int(id)
|
||||||
except: abort(400)
|
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]
|
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 = 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]))]
|
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>")
|
@app.get("/name/<id>/<name>")
|
||||||
|
|
|
@ -1,18 +1,23 @@
|
||||||
{% extends "default.html" %}
|
{% extends "default.html" %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
<pre>
|
||||||
|
|
||||||
|
|
||||||
|
</pre>
|
||||||
<table class="table table-striped mb-5">
|
<table class="table table-striped mb-5">
|
||||||
<thead class="bg-primary text-white">
|
<thead class="bg-primary text-white">
|
||||||
<tr>
|
<tr>
|
||||||
<th style="font-weight: bold">#</th>
|
<th style="font-weight: bold">#</th>
|
||||||
<th style="font-weight: bold">Name</th>
|
<th style="font-weight: bold">Name</th>
|
||||||
|
<th style="font-weight: bold">Upvotes</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="followers-table">
|
<tbody id="followers-table">
|
||||||
{% for user in users %}
|
{% for user in users %}
|
||||||
<tr>
|
<tr>
|
||||||
<td style="font-weight: bold">{{loop.index}}</td>
|
<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>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue