diff --git a/src/render_site.py b/src/render_site.py index 3fa6436..7da7d21 100644 --- a/src/render_site.py +++ b/src/render_site.py @@ -529,6 +529,42 @@ def get_player_list() -> List[Dict]: return res +@dataclass +class VariantELORow: + value_after: float + datetime_finished: datetime.datetime + + +def get_variant_rating_progression(): + cur = conn_manager.get_new_cursor() + cur.execute( + "SELECT " + " variants.rating_type," + " variants.name," + " variant_ratings.num_players," + " variant_ratings.value_after," + " games.datetime_finished " + "FROM variants " + "INNER JOIN variant_ratings" + " ON variants.id = variant_ratings.variant_id " + "INNER JOIN games " + " ON variant_ratings.league_id = games.league_id" + ) + ret = {} + for (rating_type, name, num_players, value_after, datetime_finished) in cur.fetchall(): + if rating_type not in ret.keys(): + ret[rating_type] = {} + if name not in ret[rating_type].keys(): + ret[rating_type][name] = {} + if num_players not in ret[rating_type][name].keys(): + ret[rating_type][name][num_players] = [] + ret[rating_type][name][num_players].append({ + "value_after": value_after, + "datetime_finished": datetime_finished.astimezone(datetime.timezone.utc).isoformat() + }) + return ret + + def get_total_games(): cur = conn_manager.get_new_cursor() cur.execute("SELECT COUNT(league_id) FROM games") @@ -590,6 +626,8 @@ def render_main_site(env: jinja2.Environment, out_dir: Path): games = get_games() + variant_ratings = get_variant_rating_progression() + template = env.get_template('main.html') rendered_html = template.render( leaders=leaders, @@ -601,7 +639,8 @@ def render_main_site(env: jinja2.Environment, out_dir: Path): unique_variants=build_unique_variants(variant_rows), players=players, games=[dataclasses.asdict(game) for game in games], - variant_stats=var_stats + variant_stats=var_stats, + variant_ratings=variant_ratings ) output_file = out_dir / 'index.html' diff --git a/templates/layout.html b/templates/layout.html index 6639961..1115fb5 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -20,6 +20,11 @@ + + + + + {% block navbar %}{% endblock %} {% block content %}{% endblock %} diff --git a/templates/main.html b/templates/main.html index 83266f1..c06aa26 100644 --- a/templates/main.html +++ b/templates/main.html @@ -124,6 +124,9 @@

List of played games

+

ELO progression

+ + {% endfor %} @@ -189,4 +192,42 @@ {% endfor %} + + + {% endblock %} diff --git a/templates/variant.html b/templates/variant.html index c28cb64..b0caba7 100644 --- a/templates/variant.html +++ b/templates/variant.html @@ -44,6 +44,8 @@ {% else %}
{% endif %} +

Chart

+