show urself in blocker users table

master
Aevann1 2022-09-06 04:13:43 +02:00
parent 04aab7ff0f
commit 5c854adc20
2 changed files with 16 additions and 2 deletions

View File

@ -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("/<id>/css")
def get_css(id):

View File

@ -477,12 +477,23 @@
</tr>
</thead>
{% for user, num in users16 %}
<tr {% if v.id == user.target_id %}class="self"{% endif %}>
<tr {% if v.id == user.id %}class="self"{% endif %}>
<td>{{loop.index}}</td>
<td>{% include "user_in_table.html" %}</td>
<td><a href="/blockers/{{user.id}}">{{num}}</a></td>
</tr>
{% endfor %}
{% if pos16 and (pos16[0] > 25 or not pos16[1]) %}
<tr style="border-top:2px solid var(--primary)">
<td>{{pos16[0]}}</td>
<td>
{% with user=v %}
{% include "user_in_table.html" %}
{% endwith %}
</td>
<td><a href="/blockers/{{v.id}}">{{pos16[1]}}</a></td>
</tr>
{% endif %}
</table>