From d86aa7ad21c3980c7e8256d0d3568e95d2ff8a47 Mon Sep 17 00:00:00 2001 From: Aevann Date: Fri, 15 Sep 2023 17:37:40 +0300 Subject: [PATCH] fix overridden variable --- files/classes/leaderboard.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/files/classes/leaderboard.py b/files/classes/leaderboard.py index 33730ba3c..238deefcc 100644 --- a/files/classes/leaderboard.py +++ b/files/classes/leaderboard.py @@ -188,14 +188,14 @@ class Leaderboard: @classmethod def get_avg_upvotes_lb(cls, lb_criteria, v, users, limit, desc): if lb_criteria == Post: - limit = 10 + minimum = 10 else: - limit = 100 + minimum = 100 - sq = g.db.query(lb_criteria.author_id, cls.avg_and_label(lb_criteria.upvotes, lb_criteria.author_id)).filter_by(deleted_utc=0).group_by(lb_criteria.author_id).having(func.count(lb_criteria.author_id) >= limit).subquery() + sq = g.db.query(lb_criteria.author_id, cls.avg_and_label(lb_criteria.upvotes, lb_criteria.author_id)).filter_by(deleted_utc=0).group_by(lb_criteria.author_id).having(func.count(lb_criteria.author_id) >= minimum).subquery() leaderboard = g.db.query(User, sq.c.avg).join(User, User.id == sq.c.author_id).order_by(sq.c.avg.desc()) - sq = g.db.query(lb_criteria.author_id, cls.avg_and_label(lb_criteria.upvotes, lb_criteria.author_id), cls.rank_filtered_rank_label_by_desc_avg(lb_criteria.upvotes, lb_criteria.author_id)).filter_by(deleted_utc=0).group_by(lb_criteria.author_id).having(func.count(lb_criteria.author_id) >= limit).subquery() + sq = g.db.query(lb_criteria.author_id, cls.avg_and_label(lb_criteria.upvotes, lb_criteria.author_id), cls.rank_filtered_rank_label_by_desc_avg(lb_criteria.upvotes, lb_criteria.author_id)).filter_by(deleted_utc=0).group_by(lb_criteria.author_id).having(func.count(lb_criteria.author_id) >= minimum).subquery() position = g.db.query(sq.c.rank, sq.c.avg).join(User, User.id == sq.c.author_id).filter(sq.c.author_id == v.id).limit(1).one_or_none() if not position: position = (leaderboard.count() + 1, 0) leaderboard = leaderboard.limit(limit).all()