fix naming: {current -> maximum} streak

This commit is contained in:
Maximilian Keßler 2023-11-24 12:43:26 +01:00
parent 058d87f5bf
commit 9ba98a1f47
Signed by: max
GPG Key ID: BCC5A619923C0BA5
2 changed files with 7 additions and 6 deletions

View File

@ -342,6 +342,7 @@ CREATE TABLE user_statistics (
/** We track stats separately for each variant type */
variant_type SMALLINT NOT NULL,
current_streak INTEGER,
maximum_streak INTEGER,
games_played INTEGER,
games_won INTEGER,
games_lost INTEGER GENERATED ALWAYS AS (games_played - games_won) STORED,

View File

@ -123,15 +123,15 @@ def update_user_statistics():
# so the zero value never shows up in the database if it was nonzero before.
cur.execute(
"INSERT INTO user_statistics"
" (user_id, variant_type, total_game_moves, games_played, games_won, current_streak, total_bdr, total_crits_lots)"
" (user_id, variant_type, total_game_moves, games_played, games_won, current_streak, maximum_streak, total_bdr, total_crits_lots)"
" ("
" SELECT id, %s, 0, 0, 0, 0, 0, 0 FROM users"
" SELECT id, %s, 0, 0, 0, 0, 0, 0, 0 FROM users"
" )"
"ON CONFLICT (user_id, variant_type) DO UPDATE "
"SET"
" (total_game_moves, games_played, games_won, current_streak, total_bdr, total_crits_lots)"
" (total_game_moves, games_played, games_won, current_streak, maximum_streak, total_bdr, total_crits_lots)"
" ="
" (EXCLUDED.total_game_moves, EXCLUDED.games_played, EXCLUDED.games_won, EXCLUDED.current_streak, EXCLUDED.total_bdr, EXCLUDED.total_crits_lots)",
" (EXCLUDED.total_game_moves, EXCLUDED.games_played, EXCLUDED.games_won, EXCLUDED.current_streak, EXCLUDED.maximum_streak, EXCLUDED.total_bdr, EXCLUDED.total_crits_lots)",
(rating_type,)
)
@ -180,7 +180,7 @@ def update_user_statistics():
# row ranging over all games, where we grouped by user id and rating type (Clue Starved/Non-CS currently)
# Finally, we just wrap the computed data into an insert statement to directly store it in the statistics table
cur.execute(
"INSERT INTO user_statistics (user_id, variant_type, current_streak)"
"INSERT INTO user_statistics (user_id, variant_type, maximum_streak)"
" ("
" SELECT"
" user_id,"
@ -224,7 +224,7 @@ def update_user_statistics():
" GROUP BY user_id, clue_starved"
" )"
"ON CONFLICT (user_id, variant_type) DO UPDATE "
"SET current_streak = EXCLUDED.current_streak",
"SET maximum_streak = EXCLUDED.maximum_streak",
(utils.get_rating_type(True), utils.get_rating_type(False))
)
conn_manager.get_connection().commit()