gf
This commit is contained in:
parent
83bb091810
commit
627be92a7c
4 changed files with 31 additions and 58 deletions
|
@ -52,6 +52,7 @@ class User(Base, Stndrd, Age_times):
|
|||
passhash = deferred(Column(String))
|
||||
post_count = Column(Integer, default=0)
|
||||
comment_count = Column(Integer, default=0)
|
||||
received_award_count = Column(Integer, default=0)
|
||||
created_utc = Column(Integer, default=0)
|
||||
suicide_utc = Column(Integer, default=0)
|
||||
rent_utc = Column(Integer, default=0)
|
||||
|
@ -353,18 +354,6 @@ class User(Base, Stndrd, Age_times):
|
|||
|
||||
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
|
||||
@lazy
|
||||
def post_notifications_count(self):
|
||||
|
|
|
@ -140,24 +140,11 @@ def leaderboard(v):
|
|||
users2 = users.order_by(User.stored_subscriber_count.desc()).limit(10).all()
|
||||
users3 = users.order_by(User.post_count.desc()).limit(10).all()
|
||||
users4 = users.order_by(User.comment_count.desc()).limit(10).all()
|
||||
users5 = users.order_by(User.received_award_count.desc()).limit(10).all()
|
||||
if "pcm" in request.host:
|
||||
users5 = users.order_by(User.basedcount.desc()).limit(10).all()
|
||||
users6 = users.order_by(User.basedcount.desc()).limit(10).all()
|
||||
return render_template("leaderboard.html", v=v, users1=users1, users2=users2, users3=users3, users4=users4, users5=users5, users6=users6)
|
||||
return render_template("leaderboard.html", v=v, users1=users1, users2=users2, users3=users3, users4=users4, users5=users5)
|
||||
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):
|
||||
return render_template("award_leaderboard.html", v=v, users=a_leaderboard())
|
||||
|
||||
|
||||
@cache.memoize(timeout=86400)
|
||||
def a_leaderboard():
|
||||
users = g.db.query(User).options(lazyload('*')).all()
|
||||
users = sorted(users, key=lambda x: x.received_awards_num, reverse=True)[:10]
|
||||
return users
|
||||
|
||||
|
||||
@app.get("/@<username>/css")
|
||||
def get_css(username):
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
{% extends "settings2.html" %}
|
||||
|
||||
{% block pagetitle %}Leaderboard - awards received{% 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;">Awards</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 loading="lazy" 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 %}
|
|
@ -98,6 +98,32 @@
|
|||
{% endfor %}
|
||||
</table>
|
||||
|
||||
|
||||
<pre>
|
||||
|
||||
|
||||
</pre>
|
||||
<h5 style="font-weight:bold;text-align: center;">Top 10 by received awards</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;">Received awards</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{% for user in users5 %}
|
||||
<tr>
|
||||
<td style="font-weight:bold;">{{users5.index(user)+1}}</td>
|
||||
<td><a style="color:#{{user.namecolor}}; font-weight:bold; fonts" href="/@{{user.username}}"><img loading="lazy" 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_award_count}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% if "pcm" in request.host %}
|
||||
<pre>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue