use string representations for game outcomes
This commit is contained in:
parent
de146b779a
commit
1b3ca35dd6
4 changed files with 19 additions and 13 deletions
|
@ -8,3 +8,4 @@ requests
|
|||
requests_cache
|
||||
termcolor
|
||||
jinja2
|
||||
aenum
|
||||
|
|
|
@ -91,7 +91,7 @@ class GameRow:
|
|||
league_id: int
|
||||
num_bdrs: int
|
||||
num_crits_lost: int
|
||||
game_outcomes: List[stats.GameOutcome]
|
||||
game_outcomes: List[str]
|
||||
|
||||
|
||||
def get_games():
|
||||
|
@ -147,7 +147,11 @@ def get_games():
|
|||
" ) "
|
||||
"ORDER BY league_id DESC"
|
||||
)
|
||||
return [GameRow(**row) for row in cur.fetchall()]
|
||||
res = []
|
||||
for row in cur.fetchall():
|
||||
row['game_outcomes'] = [stats.GameOutcome(outcome).string for outcome in row['game_outcomes']]
|
||||
res.append(GameRow(**row))
|
||||
return res
|
||||
|
||||
|
||||
def group_games_by_var_id_and_num_players(games: List[GameRow]):
|
||||
|
|
19
src/stats.py
19
src/stats.py
|
@ -1,4 +1,4 @@
|
|||
import enum
|
||||
import aenum
|
||||
from typing import List, Tuple, Set
|
||||
|
||||
import psycopg2.extras
|
||||
|
@ -10,14 +10,15 @@ import games_db_interface
|
|||
from log_setup import logger
|
||||
|
||||
|
||||
class GameOutcome(enum.Enum):
|
||||
win = 0
|
||||
discard_crit = 1
|
||||
bomb_crit = 2
|
||||
strikeout = 3
|
||||
bottom_deck = 4
|
||||
vote_to_kill = 5
|
||||
out_of_pace = 6
|
||||
class GameOutcome(aenum.Enum):
|
||||
_init_ = 'value string'
|
||||
win = 0, 'Win'
|
||||
discard_crit = 1, 'Discard Critical'
|
||||
bomb_crit = 2, 'Bomb Critical'
|
||||
strikeout = 3, 'Strikeout'
|
||||
bottom_deck = 4, 'Bottom Deck'
|
||||
vote_to_kill = 5, 'Vote to Kill'
|
||||
out_of_pace = 6, 'Out of Pace'
|
||||
|
||||
|
||||
class GameAnalysisResult:
|
||||
|
|
|
@ -104,9 +104,9 @@
|
|||
];
|
||||
|
||||
var table_{{num_players}} = new Tabulator("#table-{{num_players}}p", {
|
||||
height: 205,
|
||||
height: 400,
|
||||
data:tabledata_{{num_players}},
|
||||
layout:"fitColumns",
|
||||
layout:"fitDataStretch",
|
||||
columns: [
|
||||
{title: "id", field: "league_id"},
|
||||
{title: "Game", field: "game_id", formatter: "link", formatterParams:{
|
||||
|
|
Loading…
Reference in a new issue