forked from MarseyWorld/MarseyWorld
get rid of the downvote table
parent
0848008c8d
commit
dc93b5b7d2
|
@ -556,23 +556,6 @@ def leaderboard(v):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sq1 = g.db.query(Submission.author_id.label("id"), func.count(Submission.author_id).label("count")).join(Vote, Submission.id == Vote.submission_id).filter_by(vote_type=-1).group_by(Submission.author_id).subquery()
|
|
||||||
|
|
||||||
sq2 = g.db.query(Comment.author_id.label("id"), func.count(Comment.author_id).label("count")).join(CommentVote, Comment.id == CommentVote.comment_id).filter_by(vote_type=-1).group_by(Comment.author_id).subquery()
|
|
||||||
|
|
||||||
users9 = g.db.query(User, (func.coalesce(sq1.c.count, 0) + func.coalesce(sq2.c.count, 0)).label('totalcount')).outerjoin(sq1, User.id==sq1.c.id).outerjoin(sq2, User.id==sq2.c.id).order_by(desc('totalcount'))
|
|
||||||
|
|
||||||
|
|
||||||
sq = g.db.query(User.id, (func.coalesce(sq1.c.count, 0) + func.coalesce(sq2.c.count, 0)).label('totalcount'), func.rank().over(order_by=desc(func.coalesce(sq1.c.count, 0) + func.coalesce(sq2.c.count, 0))).label("rank")).outerjoin(sq1, User.id==sq1.c.id).outerjoin(sq2, User.id==sq2.c.id).order_by(desc('totalcount')).subquery()
|
|
||||||
|
|
||||||
pos9 = g.db.query(sq.c.rank, sq.c.totalcount).join(User, User.id == sq.c.id).filter(sq.c.id == v.id).limit(1).one_or_none()
|
|
||||||
|
|
||||||
if not pos9: pos9 = (users9.count()+1, 0)
|
|
||||||
users9 = users9.limit(25).all()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
users10 = users.order_by(User.truecoins.desc()).limit(25).all()
|
users10 = users.order_by(User.truecoins.desc()).limit(25).all()
|
||||||
if v in users10:
|
if v in users10:
|
||||||
pos10 = None
|
pos10 = None
|
||||||
|
@ -620,8 +603,7 @@ def leaderboard(v):
|
||||||
|
|
||||||
return render_template("leaderboard.html", v=v, users1=users1, pos1=pos1, users2=users2, pos2=pos2,
|
return render_template("leaderboard.html", v=v, users1=users1, pos1=pos1, users2=users2, pos2=pos2,
|
||||||
users3=users3, pos3=pos3, users4=users4, pos4=pos4, users5=users5, pos5=pos5,
|
users3=users3, pos3=pos3, users4=users4, pos4=pos4, users5=users5, pos5=pos5,
|
||||||
users7=users7, pos7=pos7, users9=users9, pos9=pos9,
|
users7=users7, pos7=pos7, users10=users10, pos10=pos10, users11=users11, pos11=pos11, users12=users12, pos12=pos12, users16=users16, pos16=pos16, users17=users17, pos17=pos17, users18=users18, pos18=pos18)
|
||||||
users10=users10, pos10=pos10, users11=users11, pos11=pos11, users12=users12, pos12=pos12, users16=users16, pos16=pos16, users17=users17, pos17=pos17, users18=users18, pos18=pos18)
|
|
||||||
|
|
||||||
@app.get("/<id>/css")
|
@app.get("/<id>/css")
|
||||||
def get_css(id):
|
def get_css(id):
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
<a href="#leaderboard-posts">Posts</a> •
|
<a href="#leaderboard-posts">Posts</a> •
|
||||||
<a href="#leaderboard-comments">Comments</a> •
|
<a href="#leaderboard-comments">Comments</a> •
|
||||||
<a href="#leaderboard-awards">Awards</a> •
|
<a href="#leaderboard-awards">Awards</a> •
|
||||||
<a href="#leaderboard-downvotes">Downvotes</a> •
|
|
||||||
<a href="#leaderboard-badges">Badges</a> •
|
<a href="#leaderboard-badges">Badges</a> •
|
||||||
{% if users12 %}<a href="#leaderboard-marseys">Marseys</a> • {% endif %}
|
{% if users12 %}<a href="#leaderboard-marseys">Marseys</a> • {% endif %}
|
||||||
<a href="#leaderboard-blocked">Blocked</a> •
|
<a href="#leaderboard-blocked">Blocked</a> •
|
||||||
|
@ -233,39 +232,6 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<h5 class="font-weight-bolder text-center pt-2 pb-3"><a id="leaderboard-downvotes">Top 25 by received downvotes</a></h5>
|
|
||||||
|
|
||||||
<div class="overflow-x-auto"><table class="table table-striped mb-5">
|
|
||||||
<thead class="bg-primary text-white">
|
|
||||||
<tr>
|
|
||||||
<th>#</th>
|
|
||||||
<th>Name</th>
|
|
||||||
<th>Downvotes</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for user, num in users9 %}
|
|
||||||
<tr {% if v.id == user.id %}class="self"{% endif %}>
|
|
||||||
<td>{{loop.index}}</td>
|
|
||||||
<td>{% include "user_in_table.html" %}</td>
|
|
||||||
<td>{{"{:,}".format(num)}}</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
{% if pos9 and (pos9[0] > 25 or not pos9[1]) %}
|
|
||||||
<tr style="border-top:2px solid var(--primary)">
|
|
||||||
<td>{{pos9[0]}}</td>
|
|
||||||
<td>
|
|
||||||
{% with user=v %}
|
|
||||||
{% include "user_in_table.html" %}
|
|
||||||
{% endwith %}
|
|
||||||
</td>
|
|
||||||
<td>{{"{:,}".format(pos9[1])}}</td>
|
|
||||||
</tr>
|
|
||||||
{% endif %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
<h5 class="font-weight-bolder text-center pt-2 pb-3"><a id="leaderboard-badges">Top 25 by badges</a></h5>
|
<h5 class="font-weight-bolder text-center pt-2 pb-3"><a id="leaderboard-badges">Top 25 by badges</a></h5>
|
||||||
|
|
||||||
<div class="overflow-x-auto"><table class="table table-striped mb-5">
|
<div class="overflow-x-auto"><table class="table table-striped mb-5">
|
||||||
|
|
Loading…
Reference in New Issue