From 5c854adc2083f2546b73be7ff39ce9dbb373441b Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 6 Sep 2022 04:13:43 +0200 Subject: [PATCH] show urself in blocker users table --- files/routes/users.py | 5 ++++- files/templates/leaderboard.html | 13 ++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/files/routes/users.py b/files/routes/users.py index dd52cb4b9..1703d8acc 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -574,6 +574,9 @@ def leaderboard(v): sq = g.db.query(UserBlock.target_id, func.count(UserBlock.target_id).label("n")).group_by(UserBlock.target_id).subquery() users16 = g.db.query(User, sq.c.n).join(User, User.id == sq.c.target_id).order_by(sq.c.n.desc()).limit(25).all() + sq = g.db.query(UserBlock.target_id, func.count(UserBlock.target_id).label("n"), func.rank().over(order_by=func.count(UserBlock.target_id).desc()).label("rank")).group_by(UserBlock.target_id).subquery() + pos16 = g.db.query(sq.c.rank, sq.c.n).join(User, User.id == sq.c.target_id).filter(sq.c.target_id == v.id).limit(1).one_or_none() + if not pos16: pos16 = (len(users16)+1, 0) users17 = g.db.query(User, func.count(User.owned_hats)).join(User.owned_hats).group_by(User).order_by(func.count(User.owned_hats).desc()).limit(25).all() @@ -592,7 +595,7 @@ def leaderboard(v): users6=users6, pos6=pos6, users7=users7, pos7=pos7, users9=users9_accs, pos9=pos9, users10=users10, pos10=pos10, users11=users11, pos11=pos11, users12=users12, pos12=pos12, users13=users13_accs, pos13=pos13, users14=users14, pos14=pos14, users15=users15, pos15=pos15, - users16=users16, users17=users17, users18=users18) + users16=users16, pos16=pos16, users17=users17, users18=users18) @app.get("//css") def get_css(id): diff --git a/files/templates/leaderboard.html b/files/templates/leaderboard.html index 876fb3fab..241246e9d 100644 --- a/files/templates/leaderboard.html +++ b/files/templates/leaderboard.html @@ -477,12 +477,23 @@ {% for user, num in users16 %} - + {{loop.index}} {% include "user_in_table.html" %} {{num}} {% endfor %} +{% if pos16 and (pos16[0] > 25 or not pos16[1]) %} + + {{pos16[0]}} + + {% with user=v %} + {% include "user_in_table.html" %} + {% endwith %} + + {{pos16[1]}} + +{% endif %}