fddf
This commit is contained in:
parent
8661942068
commit
41bbdf12fd
3 changed files with 48 additions and 0 deletions
|
@ -347,6 +347,18 @@ class User(Base, Stndrd, Age_times):
|
||||||
|
|
||||||
return sorted(list(awards.values()), key=lambda x: x['kind'], reverse=True)
|
return sorted(list(awards.values()), key=lambda x: x['kind'], reverse=True)
|
||||||
|
|
||||||
|
@property
|
||||||
|
@lazy
|
||||||
|
def received_awards_num(self):
|
||||||
|
|
||||||
|
posts_idlist = g.db.query(Submission.id).filter_by(author_id=self.id).subquery()
|
||||||
|
comments_idlist = g.db.query(Comment.id).filter_by(author_id=self.id).subquery()
|
||||||
|
|
||||||
|
post_awards = g.db.query(AwardRelationship).filter(AwardRelationship.submission_id.in_(posts_idlist)).count()
|
||||||
|
comment_awards = g.db.query(AwardRelationship).filter(AwardRelationship.comment_id.in_(comments_idlist)).count()
|
||||||
|
|
||||||
|
return post_awards + comment_awards
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
def post_notifications_count(self):
|
def post_notifications_count(self):
|
||||||
|
|
|
@ -142,6 +142,13 @@ def leaderboard(v):
|
||||||
users4 = users.order_by(User.comment_count.desc()).limit(10).all()
|
users4 = users.order_by(User.comment_count.desc()).limit(10).all()
|
||||||
return render_template("leaderboard.html", v=v, users1=users1, users2=users2, users3=users3, users4=users4)
|
return render_template("leaderboard.html", v=v, users1=users1, users2=users2, users3=users3, users4=users4)
|
||||||
|
|
||||||
|
@app.get("/award_leaderboard")
|
||||||
|
@auth_desired
|
||||||
|
def award_leaderboard(v):
|
||||||
|
users = g.db.query(User).options(lazyload('*')).all()
|
||||||
|
users = sorted(users, key=lambda x: x.received_awards_num)
|
||||||
|
return render_template("award_leaderboard.html", v=v, users=users)
|
||||||
|
|
||||||
@app.get("/@<username>/css")
|
@app.get("/@<username>/css")
|
||||||
def get_css(username):
|
def get_css(username):
|
||||||
user = get_user(username)
|
user = get_user(username)
|
||||||
|
|
29
files/templates/award_leaderboard.html
Normal file
29
files/templates/award_leaderboard.html
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
{% extends "settings2.html" %}
|
||||||
|
|
||||||
|
{% block pagetitle %}Leaderboard{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<pre class="d-none d-md-inline-block"></pre>
|
||||||
|
<h5 style="font-weight:bold;text-align: center;">Top 10 by awards received</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; text-align:right;">Coins</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
{% for user in users %}
|
||||||
|
<tr>
|
||||||
|
<td style="font-weight:bold;">{{users.index(user)+1}}</td>
|
||||||
|
<td><a style="color:#{{user.namecolor}}; font-weight:bold;" href="/@{{user.username}}"><img src="/uid/{{user.id}}/pic/profile" class="profile-pic-20 mr-1"><span {% if user.patron %}class="patron" style="background-color:#{{user.namecolor}};"{% endif %}>{{user.username}}</span></a></td>
|
||||||
|
<td style="font-weight:bold; text-align:right;">{{user.received_awards_num}}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
<pre>
|
||||||
|
|
||||||
|
|
||||||
|
</pre>
|
||||||
|
{% endblock %}
|
Loading…
Add table
Add a link
Reference in a new issue