forked from rDrama/rDrama
dfdf
parent
57b1d665fd
commit
9dce173e67
|
@ -328,13 +328,11 @@ class User(Base, Stndrd, Age_times):
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
def post_count(self):
|
def post_count(self):
|
||||||
|
|
||||||
return self.submissions.filter_by(is_banned=False, deleted_utc=0).count()
|
return self.submissions.filter_by(is_banned=False, deleted_utc=0).count()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
def comment_count(self):
|
def comment_count(self):
|
||||||
|
|
||||||
return self.comments.filter(Comment.parent_submission != None).filter_by(is_banned=False, deleted_utc=0).count()
|
return self.comments.filter(Comment.parent_submission != None).filter_by(is_banned=False, deleted_utc=0).count()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -45,12 +45,14 @@ def leaderboard(v):
|
||||||
users = g.db.query(User).options(lazyload('*'))
|
users = g.db.query(User).options(lazyload('*'))
|
||||||
users1 = users.order_by(User.dramacoins.desc()).limit(25).all()
|
users1 = users.order_by(User.dramacoins.desc()).limit(25).all()
|
||||||
users2 = users.order_by(User.stored_subscriber_count.desc()).limit(10).all()
|
users2 = users.order_by(User.stored_subscriber_count.desc()).limit(10).all()
|
||||||
users3 = counts()
|
users3, users4 = counts()
|
||||||
return render_template("leaderboard.html", v=v, users1=users1, users2=users2, users3=users3)
|
return render_template("leaderboard.html", v=v, users1=users1, users2=users2, users3=users3, users4=users4)
|
||||||
|
|
||||||
@cache.memoize(timeout=86400)
|
@cache.memoize(timeout=86400)
|
||||||
def counts():
|
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")
|
@app.get("/@<username>/css")
|
||||||
def get_css(username):
|
def get_css(username):
|
||||||
|
|
|
@ -75,5 +75,30 @@
|
||||||
<pre>
|
<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>
|
</pre>
|
||||||
{% endblock %}
|
{% endblock %}
|
Loading…
Reference in New Issue