use string representations for game outcomes

This commit is contained in:
Maximilian Keßler 2023-12-05 16:02:08 +01:00
parent de146b779a
commit 1b3ca35dd6
Signed by: max
GPG key ID: BCC5A619923C0BA5
4 changed files with 19 additions and 13 deletions

View file

@ -8,3 +8,4 @@ requests
requests_cache requests_cache
termcolor termcolor
jinja2 jinja2
aenum

View file

@ -91,7 +91,7 @@ class GameRow:
league_id: int league_id: int
num_bdrs: int num_bdrs: int
num_crits_lost: int num_crits_lost: int
game_outcomes: List[stats.GameOutcome] game_outcomes: List[str]
def get_games(): def get_games():
@ -147,7 +147,11 @@ def get_games():
" ) " " ) "
"ORDER BY league_id DESC" "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]): def group_games_by_var_id_and_num_players(games: List[GameRow]):

View file

@ -1,4 +1,4 @@
import enum import aenum
from typing import List, Tuple, Set from typing import List, Tuple, Set
import psycopg2.extras import psycopg2.extras
@ -10,14 +10,15 @@ import games_db_interface
from log_setup import logger from log_setup import logger
class GameOutcome(enum.Enum): class GameOutcome(aenum.Enum):
win = 0 _init_ = 'value string'
discard_crit = 1 win = 0, 'Win'
bomb_crit = 2 discard_crit = 1, 'Discard Critical'
strikeout = 3 bomb_crit = 2, 'Bomb Critical'
bottom_deck = 4 strikeout = 3, 'Strikeout'
vote_to_kill = 5 bottom_deck = 4, 'Bottom Deck'
out_of_pace = 6 vote_to_kill = 5, 'Vote to Kill'
out_of_pace = 6, 'Out of Pace'
class GameAnalysisResult: class GameAnalysisResult:

View file

@ -104,9 +104,9 @@
]; ];
var table_{{num_players}} = new Tabulator("#table-{{num_players}}p", { var table_{{num_players}} = new Tabulator("#table-{{num_players}}p", {
height: 205, height: 400,
data:tabledata_{{num_players}}, data:tabledata_{{num_players}},
layout:"fitColumns", layout:"fitDataStretch",
columns: [ columns: [
{title: "id", field: "league_id"}, {title: "id", field: "league_id"},
{title: "Game", field: "game_id", formatter: "link", formatterParams:{ {title: "Game", field: "game_id", formatter: "link", formatterParams:{