master
Aevann1 2021-07-27 02:23:41 +02:00
parent 57b1d665fd
commit 9dce173e67
3 changed files with 30 additions and 5 deletions

View File

@ -328,13 +328,11 @@ class User(Base, Stndrd, Age_times):
@property
@lazy
def post_count(self):
return self.submissions.filter_by(is_banned=False, deleted_utc=0).count()
@property
@lazy
def comment_count(self):
return self.comments.filter(Comment.parent_submission != None).filter_by(is_banned=False, deleted_utc=0).count()
@property

View File

@ -45,12 +45,14 @@ def leaderboard(v):
users = g.db.query(User).options(lazyload('*'))
users1 = users.order_by(User.dramacoins.desc()).limit(25).all()
users2 = users.order_by(User.stored_subscriber_count.desc()).limit(10).all()
users3 = counts()
return render_template("leaderboard.html", v=v, users1=users1, users2=users2, users3=users3)
users3, users4 = counts()
return render_template("leaderboard.html", v=v, users1=users1, users2=users2, users3=users3, users4=users4)
@cache.memoize(timeout=86400)
def counts():
return sorted(g.db.query(User).options(lazyload('*')).all(), key=lambda x: x.post_count, reverse=True)[:10]
users3 = sorted(g.db.query(User).options(lazyload('*')).all(), key=lambda x: x.post_count, reverse=True)[:10]
users4 = sorted(g.db.query(User).options(lazyload('*')).all(), key=lambda x: x.comment_count, reverse=True)[:10]
return users3, users4
@app.get("/@<username>/css")
def get_css(username):

View File

@ -75,5 +75,30 @@
<pre>
</pre>
<h5 style="font-weight:bold;">Top 10 dramatards by comment count</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;">Comment count</th>
</tr>
</thead>
{% for user in users3 %}
<tr>
<td style="font-weight:bold;">{{users3.index(user)+1}}</td>
<td><a style="color:#{{user.namecolor}}; font-weight:bold;" href="/@{{user.username}}">{{user.username}}</a></td>
<td style="font-weight:bold; text-align:right;">{{user.comment_count}}</td>
</tr>
{% endfor %}
</table>
<pre>
</pre>
{% endblock %}