forked from MarseyWorld/MarseyWorld
experimenting w/ leaderboard
parent
2717b93555
commit
0eb0e4ed5c
|
@ -501,26 +501,44 @@ def leaderboard(v):
|
|||
users = g.db.query(User)
|
||||
|
||||
users1 = users.order_by(User.coins.desc()).limit(25).all()
|
||||
if v in users1:
|
||||
pos1 = None
|
||||
else:
|
||||
sq = g.db.query(User.id, func.rank().over(order_by=User.coins.desc()).label("rank")).subquery()
|
||||
pos1 = g.db.query(sq.c.id, sq.c.rank).filter(sq.c.id == v.id).limit(1).one()[1]
|
||||
|
||||
users2 = users.order_by(User.stored_subscriber_count.desc()).limit(25).all()
|
||||
if v in users2:
|
||||
pos2 = None
|
||||
else:
|
||||
sq = g.db.query(User.id, func.rank().over(order_by=User.stored_subscriber_count.desc()).label("rank")).subquery()
|
||||
pos2 = g.db.query(sq.c.id, sq.c.rank).filter(sq.c.id == v.id).limit(1).one()[1]
|
||||
|
||||
users3 = users.order_by(User.post_count.desc()).limit(25).all()
|
||||
if v in users3:
|
||||
pos3 = None
|
||||
else:
|
||||
sq = g.db.query(User.id, func.rank().over(order_by=User.post_count.desc()).label("rank")).subquery()
|
||||
pos3 = g.db.query(sq.c.id, sq.c.rank).filter(sq.c.id == v.id).limit(1).one()[1]
|
||||
|
||||
users4 = users.order_by(User.comment_count.desc()).limit(25).all()
|
||||
if v in users4:
|
||||
pos4 = None
|
||||
else:
|
||||
sq = g.db.query(User.id, func.rank().over(order_by=User.comment_count.desc()).label("rank")).subquery()
|
||||
pos4 = g.db.query(sq.c.id, sq.c.rank).filter(sq.c.id == v.id).limit(1).one()[1]
|
||||
|
||||
users5 = users.order_by(User.received_award_count.desc()).limit(25).all()
|
||||
if v in users5:
|
||||
pos5 = None
|
||||
else:
|
||||
sq = g.db.query(User.id, func.rank().over(order_by=User.received_award_count.desc()).label("rank")).subquery()
|
||||
pos5 = g.db.query(sq.c.id, sq.c.rank).filter(sq.c.id == v.id).limit(1).one()[1]
|
||||
|
||||
users7 = users.order_by(User.coins_spent.desc()).limit(25).all()
|
||||
if v in users7:
|
||||
pos7 = None
|
||||
else:
|
||||
sq = g.db.query(User.id, func.rank().over(order_by=User.coins_spent.desc()).label("rank")).subquery()
|
||||
pos7 = g.db.query(sq.c.id, sq.c.rank).filter(sq.c.id == v.id).limit(1).one()[1]
|
||||
|
||||
|
@ -534,6 +552,9 @@ def leaderboard(v):
|
|||
except: pos9 = (len(users9)+1, 0)
|
||||
|
||||
users10 = users.order_by(User.truecoins.desc()).limit(25).all()
|
||||
if v in users10:
|
||||
pos10 = None
|
||||
else:
|
||||
sq = g.db.query(User.id, func.rank().over(order_by=User.truecoins.desc()).label("rank")).subquery()
|
||||
pos10 = g.db.query(sq.c.id, sq.c.rank).filter(sq.c.id == v.id).limit(1).one()[1]
|
||||
|
||||
|
@ -564,10 +585,16 @@ def leaderboard(v):
|
|||
except: pos13 = (len(users13)+1, 0)
|
||||
|
||||
users14 = users.order_by(User.winnings.desc()).limit(25).all()
|
||||
if v in users14:
|
||||
pos14 = None
|
||||
else:
|
||||
sq = g.db.query(User.id, func.rank().over(order_by=User.winnings.desc()).label("rank")).subquery()
|
||||
pos14 = g.db.query(sq.c.id, sq.c.rank).filter(sq.c.id == v.id).limit(1).one()[1]
|
||||
|
||||
users15 = users.order_by(User.winnings).limit(25).all()
|
||||
if v in users15:
|
||||
pos15 = None
|
||||
else:
|
||||
sq = g.db.query(User.id, func.rank().over(order_by=User.winnings).label("rank")).subquery()
|
||||
pos15 = g.db.query(sq.c.id, sq.c.rank).filter(sq.c.id == v.id).limit(1).one()[1]
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
<td>{{user.coins}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% if pos1 > 25 %}
|
||||
{% if pos1 %}
|
||||
<tr style="border-top:2px solid var(--primary)">
|
||||
<td>{{pos1}}</td>
|
||||
<td>
|
||||
|
@ -71,7 +71,7 @@
|
|||
<td>{{user.coins_spent}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% if pos7 > 25 %}
|
||||
{% if pos7 %}
|
||||
<tr style="border-top:2px solid var(--primary)">
|
||||
<td>{{pos7}}</td>
|
||||
<td>
|
||||
|
@ -102,7 +102,7 @@
|
|||
<td>{{user.truecoins}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% if pos10 > 25 %}
|
||||
{% if pos10 %}
|
||||
<tr style="border-top:2px solid var(--primary)">
|
||||
<td>{{pos10}}</td>
|
||||
<td>
|
||||
|
@ -133,7 +133,7 @@
|
|||
<td><a href="/@{{user.username}}/followers">{{user.stored_subscriber_count}}</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% if pos2 > 25 %}
|
||||
{% if pos2 %}
|
||||
<tr style="border-top:2px solid var(--primary)">
|
||||
<td>{{pos2}}</td>
|
||||
<td>
|
||||
|
@ -163,7 +163,7 @@
|
|||
<td>{{user.post_count}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% if pos3 > 25 %}
|
||||
{% if pos3 %}
|
||||
<tr style="border-top:2px solid var(--primary)">
|
||||
<td>{{pos3}}</td>
|
||||
<td>
|
||||
|
@ -193,7 +193,7 @@
|
|||
<td>{{user.comment_count}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% if pos4 > 25 %}
|
||||
{% if pos4 %}
|
||||
<tr style="border-top:2px solid var(--primary)">
|
||||
<td>{{pos4}}</td>
|
||||
<td>
|
||||
|
@ -223,7 +223,7 @@
|
|||
<td>{{user.received_award_count}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% if pos5 > 25 %}
|
||||
{% if pos5 %}
|
||||
<tr style="border-top:2px solid var(--primary)">
|
||||
<td>{{pos5}}</td>
|
||||
<td>
|
||||
|
@ -390,7 +390,7 @@
|
|||
<td>{{user.winnings}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% if pos14 > 25 %}
|
||||
{% if pos14 %}
|
||||
<tr style="border-top:2px solid var(--primary)">
|
||||
<td>{{pos14}}</td>
|
||||
<td>
|
||||
|
@ -420,7 +420,7 @@
|
|||
<td>{{user.winnings}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% if pos15 > 25 %}
|
||||
{% if pos15 %}
|
||||
<tr style="border-top:2px solid var(--primary)">
|
||||
<td>{{pos15}}</td>
|
||||
<td>
|
||||
|
|
Loading…
Reference in New Issue