diff --git a/src/render_site.py b/src/render_site.py index a22c9d9..d7fcba2 100644 --- a/src/render_site.py +++ b/src/render_site.py @@ -169,17 +169,6 @@ def get_games(): return res -def group_games_by_var_id_and_num_players(games: List[GameRow]): - ret = {} - for game in games: - if game.variant_id not in ret.keys(): - ret[game.variant_id] = {} - if game.num_players not in ret[game.variant_id].keys(): - ret[game.variant_id][game.num_players] = [] - ret[game.variant_id][game.num_players].append(dataclasses.asdict(game)) - return ret - - def group_games_by_var_id(games: List[GameRow]): ret = {} for game in games: @@ -382,7 +371,6 @@ def render_leaderboard(): f.write(rendered_html) games = get_games() - grouped_games_var_players = group_games_by_var_id_and_num_players(games) grouped_games_var = group_games_by_var_id(games) variant_template = env.get_template('variant.html') @@ -394,7 +382,6 @@ def render_leaderboard(): variant_stats_by_player=by_player_stats, variant_stats=variant_stats.get(variant_id, VariantStats), variant_name=variant_names[variant_id], - variant_games_by_player=grouped_games_var_players.get(variant_id, {}), variant_games=grouped_games_var.get(variant_id, []) ) diff --git a/templates/stats_table.html b/templates/stats_table.html index 4c15eeb..fbcdea2 100644 --- a/templates/stats_table.html +++ b/templates/stats_table.html @@ -50,4 +50,36 @@ -{% endmacro %}} \ No newline at end of file +{% endmacro %} + + +{% macro games_table_js(data, div_id, show_player_num, show_var_rating) %} +var table_{{div_id}} = new Tabulator("#table-{{div_id}}", { + height: 400, + data: {{data}}, + layout: "fitDataStretch", + columns: [ + {title: "id", field: "league_id"}, + {title: "Game", field: "game_id", formatter: "link", formatterParams:{ + urlPrefix: "https://hanab.live/replay/", + target:"_blank" + }}, + {% if show_player_num %} + {title: "# Players", field: "num_players"}, + {% endif %} + {% if show_var_rating %} + {title: "Rating Change", field: "variant_rating_change"}, + {title: "Rating After", field: "variant_rating_after"}, + {% endif %} + {title: "Players", field: "users"}, + {title: "Seed", field: "seed", formatter: "link", formatterParams: { + urlPrefix: "https://hanab.live/seed/", + target:"_blank" + }}, + {title: "Score", field: "score"}, + {title: "BDR", field: "num_bdrs"}, + {title: "Turns", field: "num_turns"}, + {title: "Result", field: "game_outcomes"} + ], +}); +{% endmacro %} \ No newline at end of file diff --git a/templates/variant.html b/templates/variant.html index 99e9c0b..b420f4b 100644 --- a/templates/variant.html +++ b/templates/variant.html @@ -1,5 +1,5 @@ {% extends "layout.html" %} -{% from "stats_table.html" import stats_list %} +{% from "stats_table.html" import stats_list, games_table_js %} {% block navbar %}