only show active players in leaderboards
This commit is contained in:
parent
7446bd2916
commit
d3f0f56244
1 changed files with 8 additions and 9 deletions
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue