html cleanup
This commit is contained in:
parent
1b3ca35dd6
commit
80964bbe21
4 changed files with 83 additions and 56 deletions
|
@ -67,7 +67,12 @@ body {
|
||||||
}
|
}
|
||||||
.stat-description {
|
.stat-description {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 13em;
|
width: 20em;
|
||||||
|
}
|
||||||
|
.stat-list {
|
||||||
|
padding-left: 1em;
|
||||||
|
padding-right: 1em;
|
||||||
|
list-style: inside;
|
||||||
}
|
}
|
||||||
.history-bullets {
|
.history-bullets {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -75,7 +80,7 @@ body {
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
justify-content: space-around;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
.history-bullets ul {
|
.history-bullets ul {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
|
@ -92,6 +92,8 @@ class GameRow:
|
||||||
num_bdrs: int
|
num_bdrs: int
|
||||||
num_crits_lost: int
|
num_crits_lost: int
|
||||||
game_outcomes: List[str]
|
game_outcomes: List[str]
|
||||||
|
variant_rating_change: float
|
||||||
|
variant_rating_after: float
|
||||||
|
|
||||||
|
|
||||||
def get_games():
|
def get_games():
|
||||||
|
@ -99,18 +101,20 @@ def get_games():
|
||||||
cur.execute(
|
cur.execute(
|
||||||
"SELECT"
|
"SELECT"
|
||||||
" game_data.game_id AS game_id,"
|
" game_data.game_id AS game_id,"
|
||||||
" num_players,"
|
" game_data.num_players,"
|
||||||
" users,"
|
" users,"
|
||||||
" user_ids,"
|
" user_ids,"
|
||||||
" variant_id,"
|
" game_data.variant_id,"
|
||||||
" variants.name AS variant_name,"
|
" variants.name AS variant_name,"
|
||||||
" seed,"
|
" seed,"
|
||||||
" score,"
|
" score,"
|
||||||
" num_turns,"
|
" num_turns,"
|
||||||
" league_id,"
|
" game_data.league_id,"
|
||||||
" num_bottom_deck_risks AS num_bdrs,"
|
" num_bottom_deck_risks AS num_bdrs,"
|
||||||
" num_crits_lost,"
|
" 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"
|
" FROM"
|
||||||
" ("
|
" ("
|
||||||
" SELECT "
|
" SELECT "
|
||||||
|
@ -141,15 +145,21 @@ def get_games():
|
||||||
" ON game_outcomes.game_id = game_data.game_id "
|
" ON game_outcomes.game_id = game_data.game_id "
|
||||||
"LEFT OUTER JOIN variants"
|
"LEFT OUTER JOIN variants"
|
||||||
" ON variants.id = game_data.variant_id "
|
" ON variants.id = game_data.variant_id "
|
||||||
|
"LEFT OUTER JOIN variant_ratings"
|
||||||
|
" ON variant_ratings.league_id = game_data.league_id "
|
||||||
"GROUP BY ("
|
"GROUP BY ("
|
||||||
" game_data.game_id, num_players, users, user_ids, variant_id, variants.name, seed, score, num_turns,"
|
" game_data.game_id, game_data.num_players, users, user_ids, game_data.variant_id, variants.name, seed, score, num_turns,"
|
||||||
" league_id, num_bottom_deck_risks, num_crits_lost"
|
" game_data.league_id, num_bottom_deck_risks, num_crits_lost, change, value_after"
|
||||||
" ) "
|
" ) "
|
||||||
"ORDER BY league_id DESC"
|
"ORDER BY league_id DESC"
|
||||||
)
|
)
|
||||||
res = []
|
res = []
|
||||||
for row in cur.fetchall():
|
for row in cur.fetchall():
|
||||||
row['game_outcomes'] = [stats.GameOutcome(outcome).string for outcome in row['game_outcomes']]
|
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))
|
res.append(GameRow(**row))
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
47
templates/stats_table.html
Normal file
47
templates/stats_table.html
Normal 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>
|
|
@ -42,53 +42,15 @@
|
||||||
<h3>
|
<h3>
|
||||||
League Statistics for {{variant_name}} - {{num_players}} Players
|
League Statistics for {{variant_name}} - {{num_players}} Players
|
||||||
</h3>
|
</h3>
|
||||||
<div class="history-bullets">
|
{% include "stats_table.html" %}
|
||||||
<ul>
|
<h4>
|
||||||
<li>
|
List of Played Games
|
||||||
<span class="stat-description">Rating:</span>
|
</h4>
|
||||||
{{stats.rating}}
|
{% if stats.games_played == 0 %}
|
||||||
</li>
|
There have been no games played on this variant with {{num_players}} players so far.
|
||||||
<li>
|
{% else %}
|
||||||
<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>
|
|
||||||
<div id="table-{{num_players}}p"></div>
|
<div id="table-{{num_players}}p"></div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -113,6 +75,8 @@
|
||||||
urlPrefix: "https://hanab.live/replay/",
|
urlPrefix: "https://hanab.live/replay/",
|
||||||
target:"_blank"
|
target:"_blank"
|
||||||
}},
|
}},
|
||||||
|
{title: "Rating Change", field: "variant_rating_change"},
|
||||||
|
{title: "Rating After", field: "variant_rating_after"},
|
||||||
{title: "Players", field: "users"},
|
{title: "Players", field: "users"},
|
||||||
{title: "Seed", field: "seed", formatter: "link", formatterParams: {
|
{title: "Seed", field: "seed", formatter: "link", formatterParams: {
|
||||||
urlPrefix: "https://hanab.live/seed/",
|
urlPrefix: "https://hanab.live/seed/",
|
||||||
|
@ -120,6 +84,7 @@
|
||||||
}},
|
}},
|
||||||
{title: "Score", field: "score"},
|
{title: "Score", field: "score"},
|
||||||
{title: "BDR", field: "num_bdrs"},
|
{title: "BDR", field: "num_bdrs"},
|
||||||
|
{title: "Turns", field: "num_turns"},
|
||||||
{title: "Result", field: "game_outcomes"}
|
{title: "Result", field: "game_outcomes"}
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue