From 57a5a6aa358fb50d2a2240db658fb2ebe990303e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Thu, 28 Dec 2023 23:13:45 +0100 Subject: [PATCH] variant stat overview per rating type --- src/render_site.py | 15 +++++++++++++-- templates/main.html | 4 +++- templates/stats_table.html | 6 +++--- templates/variant.html | 2 +- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/render_site.py b/src/render_site.py index d5c8577..edfe8e4 100644 --- a/src/render_site.py +++ b/src/render_site.py @@ -559,6 +559,15 @@ def build_variant_stats_by_variant(variant_rows: List[VariantRow]): return variant_stats, variant_stats_per_player, variant_names +def accumulate_variant_stats_by_rating_type(variant_rows: List[VariantRow]) -> Dict[int, VariantStats]: + res = {} + for row in variant_rows: + if row.rating_type not in res.keys(): + res[row.rating_type] = VariantStats(rating=[]) + res[row.rating_type] += row.stats + return res + + def build_unique_variants(variant_rows: List[VariantRow]): return [row for row in variant_rows if row.num_players == config.config_manager.get_config().min_player_count] @@ -570,6 +579,8 @@ def render_main_site(env: jinja2.Environment, out_dir: Path): players = get_player_list() variant_rows: List[VariantRow] = get_variant_rows() + var_stats = accumulate_variant_stats_by_rating_type(variant_rows) + print(var_stats) leaderboards = { 'Player Rating': rating_lists, @@ -588,8 +599,8 @@ def render_main_site(env: jinja2.Environment, out_dir: Path): variants_with_player_nums=variant_rows, unique_variants=build_unique_variants(variant_rows), players=players, - games=[dataclasses.asdict(game) for game in games] - # variants=variants, + games=[dataclasses.asdict(game) for game in games], + variant_stats=var_stats ) output_file = out_dir / 'index.html' diff --git a/templates/main.html b/templates/main.html index f930e6b..83266f1 100644 --- a/templates/main.html +++ b/templates/main.html @@ -1,5 +1,5 @@ {% extends "layout.html" %} -{% from "stats_table.html" import player_table_js, games_table_js %} +{% from "stats_table.html" import player_table_js, games_table_js, stats_list %} {% block navbar %}