leaderboard: fix bug with hat leaderboard

in my defense, there was a lot of stuff
master
justcool393 2022-11-01 02:21:14 -05:00
parent 9048f5127d
commit e90edce28a
1 changed files with 1 additions and 1 deletions

View File

@ -91,7 +91,7 @@ class Leaderboard:
@classmethod @classmethod
def get_hat_lb(cls, lb_criteria, v:User, db:scoped_session, users:Any, limit): def get_hat_lb(cls, lb_criteria, v:User, db:scoped_session, users:Any, limit):
leaderboard = db.query(User.id, func.count(lb_criteria)).join(lb_criteria).group_by(User).order_by(func.count(lb_criteria).desc()) leaderboard = db.query(User, func.count(lb_criteria)).join(lb_criteria).group_by(User).order_by(func.count(lb_criteria).desc())
sq = db.query(User.id, cls.count_and_label(lb_criteria), cls.rank_filtered_rank_label_by_desc(lb_criteria)).join(lb_criteria).group_by(User).subquery() sq = db.query(User.id, cls.count_and_label(lb_criteria), cls.rank_filtered_rank_label_by_desc(lb_criteria)).join(lb_criteria).group_by(User).subquery()
position = db.query(sq.c.rank, sq.c.count).filter(sq.c.id == v.id).limit(1).one_or_none() position = db.query(sq.c.rank, sq.c.count).filter(sq.c.id == v.id).limit(1).one_or_none()
if not position: position = (leaderboard.count() + 1, 0) if not position: position = (leaderboard.count() + 1, 0)