forked from MarseyWorld/MarseyWorld
sfd
parent
85baf70235
commit
35ec6a12dd
|
@ -294,27 +294,31 @@ def leaderboard(v):
|
|||
users3 = users.order_by(User.post_count.desc()).limit(25).all()
|
||||
users4 = users.order_by(User.comment_count.desc()).limit(25).all()
|
||||
users5 = users.order_by(User.received_award_count.desc()).limit(25).all()
|
||||
users7 = users.order_by(User.coins_spent.desc()).limit(25).all()
|
||||
users10 = g.db.query(User).order_by(User.truecoins.desc()).limit(25).all()
|
||||
|
||||
if 'pcmemes.net' == request.host: users6 = users.order_by(User.basedcount.desc()).limit(10).all()
|
||||
else: users6 = None
|
||||
|
||||
users7 = users.order_by(User.coins_spent.desc()).limit(25).all()
|
||||
|
||||
votes1 = g.db.query(Submission.author_id, func.count(Submission.author_id)).join(Vote, Vote.submission_id==Submission.id).filter(Vote.vote_type==-1).group_by(Submission.author_id).order_by(func.count(Submission.author_id).desc()).all()
|
||||
|
||||
votes2 = g.db.query(Comment.author_id, func.count(Comment.author_id)).join(CommentVote, CommentVote.comment_id==Comment.id).filter(CommentVote.vote_type==-1).group_by(Comment.author_id).order_by(func.count(Comment.author_id).desc()).all()
|
||||
|
||||
votes3 = Counter(dict(votes1)) + Counter(dict(votes2))
|
||||
|
||||
users8 = g.db.query(User).filter(User.id.in_(votes3.keys())).all()
|
||||
users9 = []
|
||||
for user in users8: users9.append((user, votes3[user.id]))
|
||||
|
||||
users9 = sorted(users9, key=lambda x: x[1], reverse=True)[:25]
|
||||
|
||||
if 'pcmemes.net' == request.host:
|
||||
users6 = users.order_by(User.basedcount.desc()).limit(10).all()
|
||||
return render_template(f"{template}leaderboard.html", v=v, users1=users1, users2=users2, users3=users3, users4=users4, users5=users5, users6=users6, users7=users7, users9=users9, users10=users10)
|
||||
users10 = g.db.query(User).order_by(User.truecoins.desc()).limit(25).all()
|
||||
|
||||
return render_template(f"{template}leaderboard.html", v=v, users1=users1, users2=users2, users3=users3, users4=users4, users5=users5, users7=users7, users9=users9, users10=users10)
|
||||
|
||||
badges = g.db.query(Badge.user_id, func.count(Badge.user_id)).group_by(Badge.user_id).order_by(func.count(Badge.user_id).desc()).all()
|
||||
badges = dict(badges)
|
||||
users11 = g.db.query(User).filter(User.id.in_(badges.keys())).all()
|
||||
users12 = []
|
||||
for user in users11: users12.append((user, badges[user.id]))
|
||||
users9 = sorted(users12, key=lambda x: x[1], reverse=True)[:25]
|
||||
|
||||
return render_template(f"{template}leaderboard.html", v=v, users1=users1, users2=users2, users3=users3, users4=users4, users5=users5, users6=users6, users7=users7, users9=users9, users10=users10, users12=users12)
|
||||
|
||||
|
||||
@app.get("/@<username>/css")
|
||||
|
|
|
@ -214,6 +214,35 @@
|
|||
</table>
|
||||
|
||||
|
||||
<pre>
|
||||
|
||||
|
||||
</pre>
|
||||
<h5 style="font-weight:bold;text-align: center;">Top 25 by badges</h5>
|
||||
<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">Badges</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="followers-table">
|
||||
{% for user in users12 %}
|
||||
<tr>
|
||||
<td style="font-weight: bold">{{loop.index}}</td>
|
||||
<td><a style="color:#{{user[0].namecolor}}; font-weight:bold;" href="/@{{user[0].username}}"><img alt="@{{user[0].username}}'s profile picture" loading="lazy" src="/uid/{{user[0].id}}/pic" class="pp20"><span {% if user[0].patron %}class="patron" style="background-color:#{{user[0].namecolor}};"{% endif %}>{{user[0].username}}</span></a></td>
|
||||
<td style="font-weight: bold">{{user[1]}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
{% if "pcm" in request.host %}
|
||||
|
|
Loading…
Reference in New Issue