add list of games to variant pages
This commit is contained in:
parent
1481817a72
commit
5af11b9134
2 changed files with 36 additions and 7 deletions
|
@ -97,6 +97,7 @@ class VariantRow:
|
||||||
variant_id: int
|
variant_id: int
|
||||||
name: str
|
name: str
|
||||||
num_players: int
|
num_players: int
|
||||||
|
rating_type: int
|
||||||
stats: VariantStats
|
stats: VariantStats
|
||||||
|
|
||||||
|
|
||||||
|
@ -375,6 +376,7 @@ def get_variant_rows() -> List[VariantRow]:
|
||||||
" ratings.name,"
|
" ratings.name,"
|
||||||
" ratings.num_players,"
|
" ratings.num_players,"
|
||||||
" current_rating,"
|
" current_rating,"
|
||||||
|
" rating_type,"
|
||||||
" COUNT(games.id) AS games_played,"
|
" COUNT(games.id) AS games_played,"
|
||||||
" COUNT(games.id) FILTER (WHERE ratings.num_suits * 5 = games.score) AS games_won,"
|
" COUNT(games.id) FILTER (WHERE ratings.num_suits * 5 = games.score) AS games_won,"
|
||||||
" COALESCE(SUM(game_statistics.num_bottom_deck_risks), 0) AS total_bdr,"
|
" COALESCE(SUM(game_statistics.num_bottom_deck_risks), 0) AS total_bdr,"
|
||||||
|
@ -386,6 +388,7 @@ def get_variant_rows() -> List[VariantRow]:
|
||||||
" variants.id,"
|
" variants.id,"
|
||||||
" variants.num_suits,"
|
" variants.num_suits,"
|
||||||
" variants.clue_starved,"
|
" variants.clue_starved,"
|
||||||
|
" variants.rating_type,"
|
||||||
" name,"
|
" name,"
|
||||||
" variant_base_ratings.num_players,"
|
" variant_base_ratings.num_players,"
|
||||||
" COALESCE(variant_ratings.value_after, variant_base_ratings.rating) AS current_rating "
|
" COALESCE(variant_ratings.value_after, variant_base_ratings.rating) AS current_rating "
|
||||||
|
@ -397,7 +400,7 @@ def get_variant_rows() -> List[VariantRow]:
|
||||||
" AND variant_ratings.num_players = variant_base_ratings.num_players "
|
" AND variant_ratings.num_players = variant_base_ratings.num_players "
|
||||||
" GROUP BY ("
|
" GROUP BY ("
|
||||||
" variants.id, name, variant_base_ratings.num_players, variant_base_ratings.rating,"
|
" variants.id, name, variant_base_ratings.num_players, variant_base_ratings.rating,"
|
||||||
" variant_ratings.league_id, variant_ratings.value_after"
|
" variant_ratings.league_id, variant_ratings.value_after, variants.rating_type"
|
||||||
" ) "
|
" ) "
|
||||||
" ORDER BY variants.id, variant_base_ratings.num_players, league_id DESC"
|
" ORDER BY variants.id, variant_base_ratings.num_players, league_id DESC"
|
||||||
" ) AS ratings "
|
" ) AS ratings "
|
||||||
|
@ -405,13 +408,13 @@ def get_variant_rows() -> List[VariantRow]:
|
||||||
" ON games.variant_id = ratings.id AND games.num_players = ratings.num_players "
|
" ON games.variant_id = ratings.id AND games.num_players = ratings.num_players "
|
||||||
"LEFT OUTER JOIN game_statistics"
|
"LEFT OUTER JOIN game_statistics"
|
||||||
" ON games.id = game_statistics.game_id "
|
" ON games.id = game_statistics.game_id "
|
||||||
"GROUP BY (ratings.id, ratings.name, ratings.clue_starved, ratings.num_players, ratings.current_rating, ratings.num_suits)"
|
"GROUP BY (ratings.id, ratings.name, ratings.clue_starved, ratings.num_players, ratings.current_rating, ratings.num_suits, rating_type)"
|
||||||
"ORDER BY (ratings.clue_starved, ratings.num_suits, ratings.num_players)"
|
"ORDER BY (ratings.clue_starved, ratings.num_suits, ratings.num_players)"
|
||||||
""
|
""
|
||||||
)
|
)
|
||||||
return [
|
return [
|
||||||
VariantRow(variant_id, variant_name, num_players, VariantStats(games_played, games_won, total_bdr, total_crits_lost, total_turns, round(rating)))
|
VariantRow(variant_id, variant_name, num_players, rating_type, VariantStats(games_played, games_won, total_bdr, total_crits_lost, total_turns, round(rating)))
|
||||||
for (variant_id, variant_name, num_players, rating, games_played, games_won, total_bdr, total_crits_lost, total_turns) in cur.fetchall()
|
for (variant_id, variant_name, num_players, rating, rating_type, games_played, games_won, total_bdr, total_crits_lost, total_turns) in cur.fetchall()
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -573,6 +576,8 @@ def render_main_site(env: jinja2.Environment, out_dir: Path):
|
||||||
'Maximum Streak (Current Streak)': streak_lists,
|
'Maximum Streak (Current Streak)': streak_lists,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
games = get_games()
|
||||||
|
|
||||||
template = env.get_template('main.html')
|
template = env.get_template('main.html')
|
||||||
rendered_html = template.render(
|
rendered_html = template.render(
|
||||||
leaders=leaders,
|
leaders=leaders,
|
||||||
|
@ -582,7 +587,8 @@ def render_main_site(env: jinja2.Environment, out_dir: Path):
|
||||||
latest_run=datetime.datetime.now().isoformat(),
|
latest_run=datetime.datetime.now().isoformat(),
|
||||||
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]
|
||||||
# variants=variants,
|
# variants=variants,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -674,6 +680,5 @@ def render_all():
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
get_player_list()
|
|
||||||
render_all()
|
render_all()
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{% extends "layout.html" %}
|
{% extends "layout.html" %}
|
||||||
{% from "stats_table.html" import player_table_js %}
|
{% from "stats_table.html" import player_table_js, games_table_js %}
|
||||||
|
|
||||||
{% block navbar %}
|
{% block navbar %}
|
||||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||||
|
@ -70,11 +70,20 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
let tabledata = [
|
||||||
|
{% for game in games %}
|
||||||
|
{{- game -}},
|
||||||
|
{% endfor %}
|
||||||
|
];
|
||||||
|
</script>
|
||||||
|
|
||||||
{% 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">
|
||||||
|
|
||||||
<!-- Leaderboards -->
|
<!-- Leaderboards -->
|
||||||
|
<h3>Leaderboards</h3>
|
||||||
<div id="leaderboards-{{rating_type}}-data" class="accordion">
|
<div id="leaderboards-{{rating_type}}-data" class="accordion">
|
||||||
{% for category, leaderboard in leaderboards.items() %}
|
{% for category, leaderboard in leaderboards.items() %}
|
||||||
<div class="card">
|
<div class="card">
|
||||||
|
@ -107,10 +116,17 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<!-- List of games -->
|
||||||
|
<h3>List of played games</h3>
|
||||||
|
<div id="table-{{rating_type}}"></div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
|
||||||
<div class="tab-pane fade" id="players">
|
<div class="tab-pane fade" id="players">
|
||||||
<div class="container my-5">
|
<div class="container my-5">
|
||||||
<div id="table-players"></div>
|
<div id="table-players"></div>
|
||||||
|
@ -163,4 +179,12 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
{% for rating_type in leaders %}
|
||||||
|
{{ games_table_js("tabledata", rating_type, True, False, False) }}
|
||||||
|
table_{{rating_type}}.setFilter("rating_type", "=", {{rating_type}});
|
||||||
|
{% endfor %}
|
||||||
|
</script>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in a new issue