forked from Hanabi/hanabi-league
stats page: add list of variant ratings
This commit is contained in:
parent
41e8fb9c85
commit
66a08496d8
2 changed files with 9 additions and 6 deletions
|
@ -79,13 +79,17 @@ class GeneralStats:
|
|||
|
||||
def __iadd__(self, other):
|
||||
for field in dataclasses.fields(self):
|
||||
# This is a slight hack: For lists, we left-fold into lists on concatenation
|
||||
if type(getattr(self, field.name)) == list:
|
||||
setattr(self, field.name, getattr(self, field.name) + [getattr(other, field.name)])
|
||||
else:
|
||||
setattr(self, field.name, getattr(self, field.name) + getattr(other, field.name))
|
||||
return self
|
||||
|
||||
|
||||
@dataclass
|
||||
class VariantStats(GeneralStats):
|
||||
rating: int = 0
|
||||
rating: int | List[int] = 0
|
||||
|
||||
|
||||
@dataclass
|
||||
|
@ -360,7 +364,6 @@ def get_streak_list() -> Dict[int, List[PlayerStreakEntry]]:
|
|||
)
|
||||
for (player_name, rank, user_accounts, max_streak, current_streak) in cur.fetchall():
|
||||
leaderboard[rating_type].append(PlayerStreakEntry(player_name, user_accounts, max_streak, rank, current_streak))
|
||||
print(leaderboard)
|
||||
return leaderboard
|
||||
|
||||
|
||||
|
@ -544,12 +547,13 @@ def build_variant_stats_by_variant(variant_rows: List[VariantRow]):
|
|||
if row.variant_id not in variant_stats_per_player.keys():
|
||||
variant_stats_per_player[row.variant_id] = {}
|
||||
if row.variant_id not in variant_stats.keys():
|
||||
variant_stats[row.variant_id] = VariantStats()
|
||||
variant_stats[row.variant_id] = VariantStats(rating=[])
|
||||
if row.variant_id not in variant_names.keys():
|
||||
variant_names[row.variant_id] = {}
|
||||
variant_stats_per_player[row.variant_id][row.num_players] = row.stats
|
||||
variant_names[row.variant_id] = row.name
|
||||
variant_stats[row.variant_id] += row.stats
|
||||
print(variant_stats)
|
||||
return variant_stats, variant_stats_per_player, variant_names
|
||||
|
||||
|
||||
|
@ -638,7 +642,6 @@ def render_player_pages(env: jinja2.Environment, out_dir: Path):
|
|||
|
||||
games = get_games()
|
||||
games_grouped_by_player = group_games_by_player(games)
|
||||
print(games_grouped_by_player)
|
||||
|
||||
player_template = env.get_template('player.html')
|
||||
for player_name, player_stat in player_stats.items():
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
{% if show_rating %}
|
||||
{{stats.rating}}
|
||||
{% else %}
|
||||
-
|
||||
{{ stats.rating|join(", ")}}
|
||||
{% endif %}
|
||||
</li>
|
||||
{% if show_streaks %}
|
||||
|
|
Loading…
Reference in a new issue