variant stat overview per rating type
This commit is contained in:
parent
4b3c4eb3cf
commit
57a5a6aa35
4 changed files with 20 additions and 7 deletions
|
@ -559,6 +559,15 @@ def build_variant_stats_by_variant(variant_rows: List[VariantRow]):
|
||||||
return variant_stats, variant_stats_per_player, variant_names
|
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]):
|
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]
|
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()
|
players = get_player_list()
|
||||||
|
|
||||||
variant_rows: List[VariantRow] = get_variant_rows()
|
variant_rows: List[VariantRow] = get_variant_rows()
|
||||||
|
var_stats = accumulate_variant_stats_by_rating_type(variant_rows)
|
||||||
|
print(var_stats)
|
||||||
|
|
||||||
leaderboards = {
|
leaderboards = {
|
||||||
'Player Rating': rating_lists,
|
'Player Rating': rating_lists,
|
||||||
|
@ -588,8 +599,8 @@ def render_main_site(env: jinja2.Environment, out_dir: Path):
|
||||||
variants_with_player_nums=variant_rows,
|
variants_with_player_nums=variant_rows,
|
||||||
unique_variants=build_unique_variants(variant_rows),
|
unique_variants=build_unique_variants(variant_rows),
|
||||||
players=players,
|
players=players,
|
||||||
games=[dataclasses.asdict(game) for game in games]
|
games=[dataclasses.asdict(game) for game in games],
|
||||||
# variants=variants,
|
variant_stats=var_stats
|
||||||
)
|
)
|
||||||
|
|
||||||
output_file = out_dir / 'index.html'
|
output_file = out_dir / 'index.html'
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{% extends "layout.html" %}
|
{% 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 %}
|
{% block navbar %}
|
||||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||||
|
@ -81,6 +81,8 @@
|
||||||
{% for rating_type, leaders in leaders.items() %}
|
{% for rating_type, leaders in leaders.items() %}
|
||||||
<div class="tab-pane fade" id="leaderboards-{{rating_type}}">
|
<div class="tab-pane fade" id="leaderboards-{{rating_type}}">
|
||||||
<div class="container my-5">
|
<div class="container my-5">
|
||||||
|
<h3>Global Statistics</h3>
|
||||||
|
{{ stats_list(variant_stats[rating_type], False, False, "{3p,4p,5p}x{5s,6s}") }}
|
||||||
|
|
||||||
<!-- Leaderboards -->
|
<!-- Leaderboards -->
|
||||||
<h3>Leaderboards</h3>
|
<h3>Leaderboards</h3>
|
||||||
|
|
|
@ -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 -->
|
<!-- Table for statistics of a variant -->
|
||||||
<div class="history-bullets">
|
<div class="history-bullets">
|
||||||
<ul class="stat-list">
|
<ul class="stat-list">
|
||||||
<li>
|
<li>
|
||||||
<span class="stat-description">Rating{% if not show_rating %} (3p,4p,5p){% endif %}:</span>
|
<span class="stat-description">Rating{% if not single_rating %} {{ rating_description }}{% endif %}:</span>
|
||||||
{% if show_rating %}
|
{% if single_rating %}
|
||||||
{{stats.rating}}
|
{{stats.rating}}
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ stats.rating|join(", ")}}
|
{{ stats.rating|join(", ")}}
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
<h3>
|
<h3>
|
||||||
League Statistics for {{variant_name}}
|
League Statistics for {{variant_name}}
|
||||||
</h3>
|
</h3>
|
||||||
{{ stats_list(variant_stats, False, False) }}
|
{{ stats_list(variant_stats, False, False, "(3p/4p/5p)") }}
|
||||||
<h4>
|
<h4>
|
||||||
List of Played Games
|
List of Played Games
|
||||||
</h4>
|
</h4>
|
||||||
|
|
Loading…
Reference in a new issue