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():
|
||||
cur = conn_manager.get_new_cursor()
|
||||
ret = {}
|
||||
for rating_type in [utils.get_rating_type(False), utils.get_rating_type(True)]:
|
||||
cur.execute(
|
||||
"SELECT "
|
||||
" variants.rating_type,"
|
||||
"SELECT * FROM"
|
||||
"("
|
||||
" SELECT "
|
||||
" 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"
|
||||
" DENSE_RANK() OVER (ORDER BY league_id ASC) AS rank"
|
||||
" FROM variants "
|
||||
" INNER JOIN variant_ratings"
|
||||
" ON variants.id = variant_ratings.variant_id "
|
||||
"INNER JOIN games "
|
||||
" ON variant_ratings.league_id = games.league_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 = {}
|
||||
for (rating_type, name, num_players, value_after, datetime_finished, rank) in cur.fetchall():
|
||||
if rating_type not in ret.keys():
|
||||
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({
|
||||
"value_after": value_after,
|
||||
"datetime_finished": datetime_finished.astimezone(datetime.timezone.utc).isoformat(),
|
||||
"rating": rating,
|
||||
"rank": rank
|
||||
})
|
||||
return ret
|
||||
|
|
|
@ -124,6 +124,7 @@
|
|||
<h3>List of played games</h3>
|
||||
<div id="table-{{rating_type}}"></div>
|
||||
|
||||
<br>
|
||||
<h3>ELO progression</h3>
|
||||
<canvas id="chart-{{rating_type}}"></canvas>
|
||||
|
||||
|
@ -214,12 +215,13 @@
|
|||
},
|
||||
options: {
|
||||
parsing: {
|
||||
xAxisKey: "datetime_finished",
|
||||
yAxisKey: "value_after"
|
||||
xAxisKey: "rank",
|
||||
yAxisKey: "rating"
|
||||
},
|
||||
scales: {
|
||||
x: {
|
||||
type: 'time'
|
||||
type: 'linear',
|
||||
text: 'Number of games'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue