variant stat overview per rating type

This commit is contained in:
Maximilian Keßler 2023-12-28 23:13:45 +01:00
parent 4b3c4eb3cf
commit 57a5a6aa35
Signed by: max
GPG Key ID: BCC5A619923C0BA5
4 changed files with 20 additions and 7 deletions

View File

@ -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'

View File

@ -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 %}
<nav class="navbar navbar-expand-lg navbar-light bg-light">
@ -81,6 +81,8 @@
{% for rating_type, leaders in leaders.items() %}
<div class="tab-pane fade" id="leaderboards-{{rating_type}}">
<div class="container my-5">
<h3>Global Statistics</h3>
{{ stats_list(variant_stats[rating_type], False, False, "{3p,4p,5p}x{5s,6s}") }}
<!-- Leaderboards -->
<h3>Leaderboards</h3>

View File

@ -1,10 +1,10 @@
{% macro stats_list(stats, show_rating, show_streaks) %}
{% macro stats_list(stats, single_rating, show_streaks, rating_description) %}
<!-- Table for statistics of a variant -->
<div class="history-bullets">
<ul class="stat-list">
<li>
<span class="stat-description">Rating{% if not show_rating %} (3p,4p,5p){% endif %}:</span>
{% if show_rating %}
<span class="stat-description">Rating{% if not single_rating %} {{ rating_description }}{% endif %}:</span>
{% if single_rating %}
{{stats.rating}}
{% else %}
{{ stats.rating|join(", ")}}

View File

@ -35,7 +35,7 @@
<h3>
League Statistics for {{variant_name}}
</h3>
{{ stats_list(variant_stats, False, False) }}
{{ stats_list(variant_stats, False, False, "(3p/4p/5p)") }}
<h4>
List of Played Games
</h4>