some cleanup
This commit is contained in:
parent
a377dd74af
commit
d8ef86dcfe
2 changed files with 8 additions and 19 deletions
|
@ -298,13 +298,6 @@ CREATE TABLE user_ratings (
|
|||
user_id INTEGER NOT NULL,
|
||||
type SMALLINT NOT NULL,
|
||||
|
||||
/**
|
||||
* Do we want to store this here as well? Would be nice to be displayed in some elo page imo.
|
||||
* Note: We don't need to store the result (i guess), since we can easily retrieve that info by looking up the game using the league_id
|
||||
* TODO: Since I'm not even sure on the rating model yet (I could imagine something slightly different than a team rating),
|
||||
* I'll leave this here as potentially null for now and don't implement it.
|
||||
*/
|
||||
team_rating REAL,
|
||||
change REAL NOT NULL,
|
||||
value_after REAL NOT NULL,
|
||||
|
||||
|
@ -357,14 +350,3 @@ CREATE TABLE user_statistics (
|
|||
average_game_moves REAL GENERATED ALWAYS AS (CASE WHEN games_played != 0 THEN CAST(total_game_moves AS REAL) / games_played ELSE NULL END) STORED,
|
||||
PRIMARY KEY (user_id, variant_type)
|
||||
);
|
||||
|
||||
/**
|
||||
* TODO: I'm really unsure right now how to store user-related statistics, stuff like
|
||||
* - Current streak
|
||||
* - Average bdrs/moves/whatever
|
||||
* - Cumulative stuff like 'number of wins/losses', 'number of strikeouts' etc.
|
||||
* Computationally it would just be fine to re-evaluate them whenever needed, since it's only looking stuff up in the database + some linear time calculation.
|
||||
* On the other hand, it would be sort of nice to have them here as well.
|
||||
* In the latter case, I'd probably suggest having just one row for each user that we automatically update whenever we process a game of that user,
|
||||
* together with an indication on how recent that entry is (so that on query, we always know if it's up to date).
|
||||
*/
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import enum
|
||||
from typing import List, Tuple, Set
|
||||
|
||||
import psycopg2.extras
|
||||
|
||||
from hanabi import hanab_game
|
||||
import utils
|
||||
from database import conn_manager
|
||||
|
@ -24,7 +26,7 @@ class GameAnalysisResult:
|
|||
bdrs: List[Tuple[hanab_game.DeckCard, int]],
|
||||
lost_crits: List[hanab_game.DeckCard]
|
||||
):
|
||||
self.outcome = GameOutcome
|
||||
self.outcomes = outcomes
|
||||
self.bdrs = bdrs
|
||||
self.lost_crits = lost_crits
|
||||
|
||||
|
@ -85,6 +87,11 @@ def analyze_game_and_store_stats(game_id: int):
|
|||
"SET (num_bottom_deck_risks, num_crits_lost) = (EXCLUDED.num_bottom_deck_risks, EXCLUDED.num_crits_lost)",
|
||||
(game_id, len(analysis.bdrs), len(analysis.lost_crits))
|
||||
)
|
||||
psycopg2.extras.execute_values(
|
||||
cur,
|
||||
"INSERT INTO game_outcomes (game_id, outcome) VALUES %s",
|
||||
((game_id, outcome.value) for outcome in analysis.outcomes)
|
||||
)
|
||||
conn_manager.get_connection().commit()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue