only show active players in leaderboards

This commit is contained in:
Maximilian Keßler 2023-12-24 11:35:39 +01:00
parent 7446bd2916
commit d3f0f56244
Signed by: max
GPG key ID: BCC5A619923C0BA5

View file

@ -246,19 +246,17 @@ def get_rating_lists() -> Dict[int, List[PlayerEntry]]:
" SELECT DISTINCT ON (user_accounts.user_id)" " SELECT DISTINCT ON (user_accounts.user_id)"
" player_name," " player_name,"
" string_agg(user_accounts.username, %s ORDER BY user_accounts.username) AS user_accounts," " 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 " " FROM users "
" LEFT OUTER JOIN user_ratings " " INNER JOIN user_ratings "
" ON user_ratings.user_id = users.id AND user_ratings.rating_type = %s " " 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 " " ON users.id = user_accounts.user_id "
" INNER JOIN user_base_ratings " " GROUP BY (user_accounts.user_id, player_name, value_after, league_id) "
" 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) "
" ORDER BY user_accounts.user_id, league_id DESC" " ORDER BY user_accounts.user_id, league_id DESC"
" ) AS ratings " " ) AS ratings "
"ORDER BY current_rating DESC", "ORDER BY current_rating DESC",
(", ", rating_type, rating_type) (", ", rating_type)
) )
for (player_name, user_accounts, current_rating) in cur.fetchall(): for (player_name, user_accounts, current_rating) in cur.fetchall():
leaderboard[rating_type].append(PlayerEntry(player_name, user_accounts, round(current_rating))) 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," " COALESCE(current_streak, 0) AS current_streak,"
" maximum_streak_last_game " " maximum_streak_last_game "
" FROM users " " FROM users "
" LEFT OUTER JOIN user_statistics" " INNER JOIN user_statistics"
" ON users.id = user_statistics.user_id AND variant_type = %s" " 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 " " 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) " " GROUP BY (user_accounts.user_id, player_name, maximum_streak, current_streak, maximum_streak_last_game) "
" ) AS streaks " " ) AS streaks "
# As a tiebreak, the streak that was obtained first will be shown. # As a tiebreak, the streak that was obtained first will be shown.