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,31 +531,42 @@ 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()
|
||||||
|
ret = {}
|
||||||
|
for rating_type in [utils.get_rating_type(False), utils.get_rating_type(True)]:
|
||||||
cur.execute(
|
cur.execute(
|
||||||
|
"SELECT * FROM"
|
||||||
|
"("
|
||||||
" SELECT "
|
" SELECT "
|
||||||
" variants.rating_type,"
|
|
||||||
" variants.name,"
|
" variants.name,"
|
||||||
" variant_ratings.num_players,"
|
" variant_ratings.num_players,"
|
||||||
" variant_ratings.value_after,"
|
" variant_ratings.value_after,"
|
||||||
" games.datetime_finished,"
|
" DENSE_RANK() OVER (ORDER BY league_id ASC) AS rank"
|
||||||
" dense_rank() over (order by games.league_id desc) "
|
|
||||||
" FROM variants "
|
" FROM variants "
|
||||||
" INNER JOIN variant_ratings"
|
" INNER JOIN variant_ratings"
|
||||||
" ON variants.id = variant_ratings.variant_id "
|
" ON variants.id = variant_ratings.variant_id "
|
||||||
"INNER JOIN games "
|
" WHERE variants.rating_type = %s "
|
||||||
" ON variant_ratings.league_id = games.league_id"
|
" 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 = {}
|
|
||||||
for (rating_type, name, num_players, value_after, datetime_finished, rank) in cur.fetchall():
|
|
||||||
if rating_type not in ret.keys():
|
|
||||||
ret[rating_type] = {}
|
ret[rating_type] = {}
|
||||||
|
for (name, num_players, rating, rank) in cur.fetchall():
|
||||||
if name not in ret[rating_type].keys():
|
if name not in ret[rating_type].keys():
|
||||||
ret[rating_type][name] = {}
|
ret[rating_type][name] = {}
|
||||||
if num_players not in ret[rating_type][name].keys():
|
if num_players not in ret[rating_type][name].keys():
|
||||||
ret[rating_type][name][num_players] = []
|
ret[rating_type][name][num_players] = []
|
||||||
ret[rating_type][name][num_players].append({
|
ret[rating_type][name][num_players].append({
|
||||||
"value_after": value_after,
|
"rating": rating,
|
||||||
"datetime_finished": datetime_finished.astimezone(datetime.timezone.utc).isoformat(),
|
|
||||||
"rank": rank
|
"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