From 0848008c8d5ad01daa4d4feab5ffd5ec24323321 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 7 Oct 2022 00:10:10 +0200 Subject: [PATCH] fix prev leaderboard commit --- files/routes/users.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/files/routes/users.py b/files/routes/users.py index f1ced48d8..c2e415171 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -561,12 +561,12 @@ def leaderboard(v): sq2 = g.db.query(Comment.author_id.label("id"), func.count(Comment.author_id).label("count")).join(CommentVote, Comment.id == CommentVote.comment_id).filter_by(vote_type=-1).group_by(Comment.author_id).subquery() - users9 = g.db.query(User, (func.coalesce(sq1.c.count, 0) + func.coalesce(sq2.c.count, 0)).label("count")).outerjoin(sq1, User.id==sq1.c.id).outerjoin(sq2, User.id==sq2.c.id).order_by(desc('count')) + users9 = g.db.query(User, (func.coalesce(sq1.c.count, 0) + func.coalesce(sq2.c.count, 0)).label('totalcount')).outerjoin(sq1, User.id==sq1.c.id).outerjoin(sq2, User.id==sq2.c.id).order_by(desc('totalcount')) - sq = g.db.query(User.id, (func.coalesce(sq1.c.count, 0) + func.coalesce(sq2.c.count, 0)).label("count"), func.rank().over(order_by=desc('count')).label("rank")).outerjoin(sq1, User.id==sq1.c.id).outerjoin(sq2, User.id==sq2.c.id).order_by(desc('count')).subquery() + sq = g.db.query(User.id, (func.coalesce(sq1.c.count, 0) + func.coalesce(sq2.c.count, 0)).label('totalcount'), func.rank().over(order_by=desc(func.coalesce(sq1.c.count, 0) + func.coalesce(sq2.c.count, 0))).label("rank")).outerjoin(sq1, User.id==sq1.c.id).outerjoin(sq2, User.id==sq2.c.id).order_by(desc('totalcount')).subquery() - pos9 = g.db.query(sq.c.rank, sq.c.count).join(User, User.id == sq.c.id).filter(sq.c.id == v.id).limit(1).one_or_none() + pos9 = g.db.query(sq.c.rank, sq.c.totalcount).join(User, User.id == sq.c.id).filter(sq.c.id == v.id).limit(1).one_or_none() if not pos9: pos9 = (users9.count()+1, 0) users9 = users9.limit(25).all()