forked from rDrama/rDrama
experimenting w/ leaderboard
parent
2717b93555
commit
0eb0e4ed5c
|
@ -501,28 +501,46 @@ def leaderboard(v):
|
||||||
users = g.db.query(User)
|
users = g.db.query(User)
|
||||||
|
|
||||||
users1 = users.order_by(User.coins.desc()).limit(25).all()
|
users1 = users.order_by(User.coins.desc()).limit(25).all()
|
||||||
sq = g.db.query(User.id, func.rank().over(order_by=User.coins.desc()).label("rank")).subquery()
|
if v in users1:
|
||||||
pos1 = g.db.query(sq.c.id, sq.c.rank).filter(sq.c.id == v.id).limit(1).one()[1]
|
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()
|
users2 = users.order_by(User.stored_subscriber_count.desc()).limit(25).all()
|
||||||
sq = g.db.query(User.id, func.rank().over(order_by=User.stored_subscriber_count.desc()).label("rank")).subquery()
|
if v in users2:
|
||||||
pos2 = g.db.query(sq.c.id, sq.c.rank).filter(sq.c.id == v.id).limit(1).one()[1]
|
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()
|
users3 = users.order_by(User.post_count.desc()).limit(25).all()
|
||||||
sq = g.db.query(User.id, func.rank().over(order_by=User.post_count.desc()).label("rank")).subquery()
|
if v in users3:
|
||||||
pos3 = g.db.query(sq.c.id, sq.c.rank).filter(sq.c.id == v.id).limit(1).one()[1]
|
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()
|
users4 = users.order_by(User.comment_count.desc()).limit(25).all()
|
||||||
sq = g.db.query(User.id, func.rank().over(order_by=User.comment_count.desc()).label("rank")).subquery()
|
if v in users4:
|
||||||
pos4 = g.db.query(sq.c.id, sq.c.rank).filter(sq.c.id == v.id).limit(1).one()[1]
|
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()
|
users5 = users.order_by(User.received_award_count.desc()).limit(25).all()
|
||||||
sq = g.db.query(User.id, func.rank().over(order_by=User.received_award_count.desc()).label("rank")).subquery()
|
if v in users5:
|
||||||
pos5 = g.db.query(sq.c.id, sq.c.rank).filter(sq.c.id == v.id).limit(1).one()[1]
|
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()
|
users7 = users.order_by(User.coins_spent.desc()).limit(25).all()
|
||||||
sq = g.db.query(User.id, func.rank().over(order_by=User.coins_spent.desc()).label("rank")).subquery()
|
if v in users7:
|
||||||
pos7 = g.db.query(sq.c.id, sq.c.rank).filter(sq.c.id == v.id).limit(1).one()[1]
|
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]
|
||||||
|
|
||||||
|
|
||||||
users9_accs = g.db.query(User).filter(User.id.in_(users9_1)).all()
|
users9_accs = g.db.query(User).filter(User.id.in_(users9_1)).all()
|
||||||
|
@ -534,8 +552,11 @@ def leaderboard(v):
|
||||||
except: pos9 = (len(users9)+1, 0)
|
except: pos9 = (len(users9)+1, 0)
|
||||||
|
|
||||||
users10 = users.order_by(User.truecoins.desc()).limit(25).all()
|
users10 = users.order_by(User.truecoins.desc()).limit(25).all()
|
||||||
sq = g.db.query(User.id, func.rank().over(order_by=User.truecoins.desc()).label("rank")).subquery()
|
if v in users10:
|
||||||
pos10 = g.db.query(sq.c.id, sq.c.rank).filter(sq.c.id == v.id).limit(1).one()[1]
|
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]
|
||||||
|
|
||||||
sq = g.db.query(Badge.user_id, func.count(Badge.user_id).label("count"), func.rank().over(order_by=func.count(Badge.user_id).desc()).label("rank")).group_by(Badge.user_id).subquery()
|
sq = g.db.query(Badge.user_id, func.count(Badge.user_id).label("count"), func.rank().over(order_by=func.count(Badge.user_id).desc()).label("rank")).group_by(Badge.user_id).subquery()
|
||||||
users11 = g.db.query(User, sq.c.count).join(sq, User.id==sq.c.user_id).order_by(sq.c.count.desc())
|
users11 = g.db.query(User, sq.c.count).join(sq, User.id==sq.c.user_id).order_by(sq.c.count.desc())
|
||||||
|
@ -564,12 +585,18 @@ def leaderboard(v):
|
||||||
except: pos13 = (len(users13)+1, 0)
|
except: pos13 = (len(users13)+1, 0)
|
||||||
|
|
||||||
users14 = users.order_by(User.winnings.desc()).limit(25).all()
|
users14 = users.order_by(User.winnings.desc()).limit(25).all()
|
||||||
sq = g.db.query(User.id, func.rank().over(order_by=User.winnings.desc()).label("rank")).subquery()
|
if v in users14:
|
||||||
pos14 = g.db.query(sq.c.id, sq.c.rank).filter(sq.c.id == v.id).limit(1).one()[1]
|
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()
|
users15 = users.order_by(User.winnings).limit(25).all()
|
||||||
sq = g.db.query(User.id, func.rank().over(order_by=User.winnings).label("rank")).subquery()
|
if v in users15:
|
||||||
pos15 = g.db.query(sq.c.id, sq.c.rank).filter(sq.c.id == v.id).limit(1).one()[1]
|
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]
|
||||||
|
|
||||||
sq = g.db.query(UserBlock.target_id, func.count(UserBlock.target_id).label("count")).group_by(UserBlock.target_id).subquery()
|
sq = g.db.query(UserBlock.target_id, func.count(UserBlock.target_id).label("count")).group_by(UserBlock.target_id).subquery()
|
||||||
users16 = g.db.query(User, sq.c.count).join(User, User.id == sq.c.target_id).order_by(sq.c.count.desc()).limit(25).all()
|
users16 = g.db.query(User, sq.c.count).join(User, User.id == sq.c.target_id).order_by(sq.c.count.desc()).limit(25).all()
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
<td>{{user.coins}}</td>
|
<td>{{user.coins}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if pos1 > 25 %}
|
{% if pos1 %}
|
||||||
<tr style="border-top:2px solid var(--primary)">
|
<tr style="border-top:2px solid var(--primary)">
|
||||||
<td>{{pos1}}</td>
|
<td>{{pos1}}</td>
|
||||||
<td>
|
<td>
|
||||||
|
@ -71,7 +71,7 @@
|
||||||
<td>{{user.coins_spent}}</td>
|
<td>{{user.coins_spent}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if pos7 > 25 %}
|
{% if pos7 %}
|
||||||
<tr style="border-top:2px solid var(--primary)">
|
<tr style="border-top:2px solid var(--primary)">
|
||||||
<td>{{pos7}}</td>
|
<td>{{pos7}}</td>
|
||||||
<td>
|
<td>
|
||||||
|
@ -102,7 +102,7 @@
|
||||||
<td>{{user.truecoins}}</td>
|
<td>{{user.truecoins}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if pos10 > 25 %}
|
{% if pos10 %}
|
||||||
<tr style="border-top:2px solid var(--primary)">
|
<tr style="border-top:2px solid var(--primary)">
|
||||||
<td>{{pos10}}</td>
|
<td>{{pos10}}</td>
|
||||||
<td>
|
<td>
|
||||||
|
@ -133,7 +133,7 @@
|
||||||
<td><a href="/@{{user.username}}/followers">{{user.stored_subscriber_count}}</a></td>
|
<td><a href="/@{{user.username}}/followers">{{user.stored_subscriber_count}}</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if pos2 > 25 %}
|
{% if pos2 %}
|
||||||
<tr style="border-top:2px solid var(--primary)">
|
<tr style="border-top:2px solid var(--primary)">
|
||||||
<td>{{pos2}}</td>
|
<td>{{pos2}}</td>
|
||||||
<td>
|
<td>
|
||||||
|
@ -163,7 +163,7 @@
|
||||||
<td>{{user.post_count}}</td>
|
<td>{{user.post_count}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if pos3 > 25 %}
|
{% if pos3 %}
|
||||||
<tr style="border-top:2px solid var(--primary)">
|
<tr style="border-top:2px solid var(--primary)">
|
||||||
<td>{{pos3}}</td>
|
<td>{{pos3}}</td>
|
||||||
<td>
|
<td>
|
||||||
|
@ -193,7 +193,7 @@
|
||||||
<td>{{user.comment_count}}</td>
|
<td>{{user.comment_count}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if pos4 > 25 %}
|
{% if pos4 %}
|
||||||
<tr style="border-top:2px solid var(--primary)">
|
<tr style="border-top:2px solid var(--primary)">
|
||||||
<td>{{pos4}}</td>
|
<td>{{pos4}}</td>
|
||||||
<td>
|
<td>
|
||||||
|
@ -223,7 +223,7 @@
|
||||||
<td>{{user.received_award_count}}</td>
|
<td>{{user.received_award_count}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if pos5 > 25 %}
|
{% if pos5 %}
|
||||||
<tr style="border-top:2px solid var(--primary)">
|
<tr style="border-top:2px solid var(--primary)">
|
||||||
<td>{{pos5}}</td>
|
<td>{{pos5}}</td>
|
||||||
<td>
|
<td>
|
||||||
|
@ -390,7 +390,7 @@
|
||||||
<td>{{user.winnings}}</td>
|
<td>{{user.winnings}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if pos14 > 25 %}
|
{% if pos14 %}
|
||||||
<tr style="border-top:2px solid var(--primary)">
|
<tr style="border-top:2px solid var(--primary)">
|
||||||
<td>{{pos14}}</td>
|
<td>{{pos14}}</td>
|
||||||
<td>
|
<td>
|
||||||
|
@ -420,7 +420,7 @@
|
||||||
<td>{{user.winnings}}</td>
|
<td>{{user.winnings}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if pos15 > 25 %}
|
{% if pos15 %}
|
||||||
<tr style="border-top:2px solid var(--primary)">
|
<tr style="border-top:2px solid var(--primary)">
|
||||||
<td>{{pos15}}</td>
|
<td>{{pos15}}</td>
|
||||||
<td>
|
<td>
|
||||||
|
|
Loading…
Reference in New Issue