File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -1513,11 +1513,27 @@ export async function getStatsCanvasUserData(
15131513 date : r . date as Date ,
15141514 } ) )
15151515
1516+ // Get queue default_elo for initial data point
1517+ const queueSettings = await getQueueSettings ( queueId )
1518+ const defaultElo = queueSettings . default_elo
1519+
15161520 const totalChange = eloChanges . reduce ( ( sum , r ) => sum + r . change , 0 )
15171521 let running = ( p . elo ?? 0 ) - totalChange
1518- const elo_graph_data = eloChanges . map ( ( r ) => {
1522+
1523+ const elo_graph_data : { date : Date ; rating : number } [ ] = [ ]
1524+
1525+ // Add initial starting point if there are any matches
1526+ if ( eloChanges . length > 0 ) {
1527+ const firstMatchDate = new Date ( eloChanges [ 0 ] . date )
1528+ const startDate = new Date ( firstMatchDate . getTime ( ) - 1000 ) // 1 second before
1529+ elo_graph_data . push ( { date : startDate , rating : defaultElo } )
1530+ }
1531+
1532+ // Add all match data points
1533+ eloChanges . forEach ( ( r ) => {
15191534 running += r . change
1520- return { date : r . date , rating : running }
1535+ const clampedRating = Math . max ( 0 , running ) // Makes sure it stays within the range of 0-9999
1536+ elo_graph_data . push ( { date : r . date , rating : clampedRating } )
15211537 } )
15221538
15231539 // Calculate percentiles for each stat using CTEs
You can’t perform that action at this time.
0 commit comments