From d3f0f5624463812635b8b08b8fc4eccfe04b500c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Sun, 24 Dec 2023 11:35:39 +0100 Subject: [PATCH] only show active players in leaderboards --- src/render_site.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/render_site.py b/src/render_site.py index 937799f..3d86ee6 100644 --- a/src/render_site.py +++ b/src/render_site.py @@ -246,19 +246,17 @@ def get_rating_lists() -> Dict[int, List[PlayerEntry]]: " SELECT DISTINCT ON (user_accounts.user_id)" " player_name," " string_agg(user_accounts.username, %s ORDER BY user_accounts.username) AS user_accounts," - " COALESCE(value_after, rating) AS current_rating" + " value_after AS current_rating" " FROM users " - " LEFT OUTER JOIN user_ratings " + " INNER JOIN user_ratings " " ON user_ratings.user_id = users.id AND user_ratings.rating_type = %s " - " LEFT OUTER JOIN user_accounts " + " INNER JOIN user_accounts " " ON users.id = user_accounts.user_id " - " INNER JOIN user_base_ratings " - " ON users.id = user_base_ratings.user_id AND user_base_ratings.rating_type = %s" - " GROUP BY (user_accounts.user_id, player_name, value_after, league_id, rating) " + " GROUP BY (user_accounts.user_id, player_name, value_after, league_id) " " ORDER BY user_accounts.user_id, league_id DESC" " ) AS ratings " "ORDER BY current_rating DESC", - (", ", rating_type, rating_type) + (", ", rating_type) ) for (player_name, user_accounts, current_rating) in cur.fetchall(): leaderboard[rating_type].append(PlayerEntry(player_name, user_accounts, round(current_rating))) @@ -313,10 +311,11 @@ def get_streak_list(): " COALESCE(current_streak, 0) AS current_streak," " maximum_streak_last_game " " FROM users " - " LEFT OUTER JOIN user_statistics" + " INNER JOIN user_statistics" " ON users.id = user_statistics.user_id AND variant_type = %s" - " LEFT OUTER JOIN user_accounts " + " INNER JOIN user_accounts " " ON users.id = user_accounts.user_id " + " where games_played != 0" " GROUP BY (user_accounts.user_id, player_name, maximum_streak, current_streak, maximum_streak_last_game) " " ) AS streaks " # As a tiebreak, the streak that was obtained first will be shown.