html cleanup

This commit is contained in:
Maximilian Keßler 2023-12-05 17:28:55 +01:00
parent 1b3ca35dd6
commit 80964bbe21
Signed by: max
GPG key ID: BCC5A619923C0BA5
4 changed files with 83 additions and 56 deletions

View file

@ -67,7 +67,12 @@ body {
}
.stat-description {
display: inline-block;
width: 13em;
width: 20em;
}
.stat-list {
padding-left: 1em;
padding-right: 1em;
list-style: inside;
}
.history-bullets {
display: flex;
@ -75,7 +80,7 @@ body {
flex-wrap: wrap;
width: 100%;
align-items: flex-start;
justify-content: space-around;
justify-content: space-between;
}
.history-bullets ul {
flex-direction: column;

View file

@ -92,6 +92,8 @@ class GameRow:
num_bdrs: int
num_crits_lost: int
game_outcomes: List[str]
variant_rating_change: float
variant_rating_after: float
def get_games():
@ -99,18 +101,20 @@ def get_games():
cur.execute(
"SELECT"
" game_data.game_id AS game_id,"
" num_players,"
" game_data.num_players,"
" users,"
" user_ids,"
" variant_id,"
" game_data.variant_id,"
" variants.name AS variant_name,"
" seed,"
" score,"
" num_turns,"
" league_id,"
" game_data.league_id,"
" num_bottom_deck_risks AS num_bdrs,"
" num_crits_lost,"
" coalesce(array_agg(outcome ORDER BY outcome) FILTER (WHERE outcome IS NOT NULL), '{}') AS game_outcomes"
" coalesce(array_agg(outcome ORDER BY outcome) FILTER (WHERE outcome IS NOT NULL), '{}') AS game_outcomes,"
" change AS variant_rating_change,"
" value_after AS variant_rating_after"
" FROM"
" ("
" SELECT "
@ -139,17 +143,23 @@ def get_games():
" ) AS game_data "
"LEFT OUTER JOIN game_outcomes "
" ON game_outcomes.game_id = game_data.game_id "
" LEFT OUTER JOIN variants"
"LEFT OUTER JOIN variants"
" ON variants.id = game_data.variant_id "
"LEFT OUTER JOIN variant_ratings"
" ON variant_ratings.league_id = game_data.league_id "
"GROUP BY ("
" game_data.game_id, num_players, users, user_ids, variant_id, variants.name, seed, score, num_turns,"
" league_id, num_bottom_deck_risks, num_crits_lost"
" game_data.game_id, game_data.num_players, users, user_ids, game_data.variant_id, variants.name, seed, score, num_turns,"
" game_data.league_id, num_bottom_deck_risks, num_crits_lost, change, value_after"
" ) "
"ORDER BY league_id DESC"
)
res = []
for row in cur.fetchall():
row['game_outcomes'] = [stats.GameOutcome(outcome).string for outcome in row['game_outcomes']]
if row['variant_rating_change'] is not None:
row['variant_rating_change'] = round(row['variant_rating_change'], 2)
if row['variant_rating_after'] is not None:
row['variant_rating_after'] = round(row['variant_rating_after'], 2)
res.append(GameRow(**row))
return res

View file

@ -0,0 +1,47 @@
<!-- Table for statistics of a variant -->
<div class="history-bullets">
<ul class="stat-list">
<li>
<span class="stat-description">Rating:</span>
{{stats.rating}}
</li>
<li>
<span class="stat-description">Total Perfect Scores:</span>
{{stats.games_won}}
</li>
<li>
<span class="stat-description">Total Bottom Deck Risk:</span>
{{stats.total_bdr}}
</li>
<li>
<span class="stat-description">Total Crits Lost:</span>
{{stats.total_crits_lost}}
</li>
<li>
<span class="stat-description">Total Turns Taken:</span>
{{stats.total_moves}}
</li>
</ul>
<ul class="stat-list">
<li>
<span class="stat-description">Total Games Played:</span>
{{stats.games_played}}
</li>
<li>
<span class="stat-description">Winrate:</span>
{{stats.winrate}}%
</li>
<li>
<span class="stat-description">Average Bottom Deck Risk:</span>
{{stats.average_bdr}}
</li>
<li>
<span class="stat-description">Average Crits Lost:</span>
{{stats.average_crits_lost}}
</li>
<li>
<span class="stat-description">Average Turns Taken:</span>
{{stats.average_moves}}
</li>
</ul>
</div>

View file

@ -42,53 +42,15 @@
<h3>
League Statistics for {{variant_name}} - {{num_players}} Players
</h3>
<div class="history-bullets">
<ul>
<li>
<span class="stat-description">Rating:</span>
{{stats.rating}}
</li>
<li>
<span class="stat-description">Total Perfect Scores:</span>
{{stats.games_won}}
</li>
<li>
<span class="stat-description">Total Bottom Deck Risk:</span>
{{stats.total_bdr}}
</li>
<li>
<span class="stat-description">Total Crits Lost:</span>
{{stats.total_crits_lost}}
</li>
<li>
<span class="stat-description">Total Turns Taken:</span>
{{stats.total_moves}}
</li>
</ul>
<ul>
<li>
<span class="stat-description">Total Games Played:</span>
{{stats.games_played}}
</li>
<li>
<span class="stat-description">Winrate:</span>
{{stats.winrate}}%
</li>
<li>
<span class="stat-description">Average Bottom Deck Risk:</span>
{{stats.average_bdr}}
</li>
<li>
<span class="stat-description">Average Crits Lost:</span>
{{stats.average_crits_lost}}
</li>
<li>
<span class="stat-description">Average Turns Taken:</span>
{{stats.average_moves}}
</li>
</ul>
</div>
{% include "stats_table.html" %}
<h4>
List of Played Games
</h4>
{% if stats.games_played == 0 %}
There have been no games played on this variant with {{num_players}} players so far.
{% else %}
<div id="table-{{num_players}}p"></div>
{% endif %}
</div>
</div>
{% endfor %}
@ -113,6 +75,8 @@
urlPrefix: "https://hanab.live/replay/",
target:"_blank"
}},
{title: "Rating Change", field: "variant_rating_change"},
{title: "Rating After", field: "variant_rating_after"},
{title: "Players", field: "users"},
{title: "Seed", field: "seed", formatter: "link", formatterParams: {
urlPrefix: "https://hanab.live/seed/",
@ -120,6 +84,7 @@
}},
{title: "Score", field: "score"},
{title: "BDR", field: "num_bdrs"},
{title: "Turns", field: "num_turns"},
{title: "Result", field: "game_outcomes"}
],
});