forked from Hanabi/hanabi-league
change x-axis scale: number games for elo charts
This commit is contained in:
parent
5a7db5a873
commit
e249ff5cf7
2 changed files with 42 additions and 29 deletions
|
@ -531,33 +531,44 @@ def get_player_list() -> List[Dict]:
|
||||||
|
|
||||||
def get_variant_rating_progression():
|
def get_variant_rating_progression():
|
||||||
cur = conn_manager.get_new_cursor()
|
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,"
|
|
||||||
" dense_rank() over (order by games.league_id desc) "
|
|
||||||
"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 = {}
|
ret = {}
|
||||||
for (rating_type, name, num_players, value_after, datetime_finished, rank) in cur.fetchall():
|
for rating_type in [utils.get_rating_type(False), utils.get_rating_type(True)]:
|
||||||
if rating_type not in ret.keys():
|
cur.execute(
|
||||||
ret[rating_type] = {}
|
"SELECT * FROM"
|
||||||
if name not in ret[rating_type].keys():
|
"("
|
||||||
ret[rating_type][name] = {}
|
" SELECT "
|
||||||
if num_players not in ret[rating_type][name].keys():
|
" variants.name,"
|
||||||
ret[rating_type][name][num_players] = []
|
" variant_ratings.num_players,"
|
||||||
ret[rating_type][name][num_players].append({
|
" variant_ratings.value_after,"
|
||||||
"value_after": value_after,
|
" DENSE_RANK() OVER (ORDER BY league_id ASC) AS rank"
|
||||||
"datetime_finished": datetime_finished.astimezone(datetime.timezone.utc).isoformat(),
|
" FROM variants "
|
||||||
"rank": rank
|
" INNER JOIN variant_ratings"
|
||||||
})
|
" ON variants.id = variant_ratings.variant_id "
|
||||||
|
" WHERE variants.rating_type = %s "
|
||||||
|
" UNION "
|
||||||
|
" SELECT "
|
||||||
|
" variants.name,"
|
||||||
|
" variant_base_ratings.num_players,"
|
||||||
|
" variant_base_ratings.rating,"
|
||||||
|
" 0 AS rank"
|
||||||
|
" FROM variants "
|
||||||
|
" INNER JOIN variant_base_ratings"
|
||||||
|
" ON variants.id = variant_base_ratings.variant_id "
|
||||||
|
" WHERE variants.rating_type = %s"
|
||||||
|
") "
|
||||||
|
"ORDER BY rank",
|
||||||
|
(rating_type, rating_type)
|
||||||
|
)
|
||||||
|
ret[rating_type] = {}
|
||||||
|
for (name, num_players, rating, rank) in cur.fetchall():
|
||||||
|
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({
|
||||||
|
"rating": rating,
|
||||||
|
"rank": rank
|
||||||
|
})
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -124,6 +124,7 @@
|
||||||
<h3>List of played games</h3>
|
<h3>List of played games</h3>
|
||||||
<div id="table-{{rating_type}}"></div>
|
<div id="table-{{rating_type}}"></div>
|
||||||
|
|
||||||
|
<br>
|
||||||
<h3>ELO progression</h3>
|
<h3>ELO progression</h3>
|
||||||
<canvas id="chart-{{rating_type}}"></canvas>
|
<canvas id="chart-{{rating_type}}"></canvas>
|
||||||
|
|
||||||
|
@ -214,12 +215,13 @@
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
parsing: {
|
parsing: {
|
||||||
xAxisKey: "datetime_finished",
|
xAxisKey: "rank",
|
||||||
yAxisKey: "value_after"
|
yAxisKey: "rating"
|
||||||
},
|
},
|
||||||
scales: {
|
scales: {
|
||||||
x: {
|
x: {
|
||||||
type: 'time'
|
type: 'linear',
|
||||||
|
text: 'Number of games'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue