Skip to content

Commit

Permalink
fix(ranking): 修复对于第一次参赛的选手,获取初始分数错误
Browse files Browse the repository at this point in the history
  • Loading branch information
XYShaoKang committed Apr 16, 2023
1 parent 539180e commit 70e5603
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/content/pages/ranking/rankSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ export const fetchUserRating = createAsyncThunk<
res = await query({ message: { type: 'get-user-ranking', username } })
}
const { start_time } = getState().contestInfos[contestSlug].info!.contest
const history = res.userContestRankingHistory.filter(a => a.attended)

let l = 0,
const history = res.userContestRankingHistory?.filter(a => a.attended) ?? []
let l = -1,
r = history.length - 1
while (l < r) {
const m = (l + r + 1) >> 1
Expand All @@ -194,7 +194,7 @@ export const fetchUserRating = createAsyncThunk<
}
}

return { oldRating: history[l].rating ?? 1500, acc: l + 1 }
return { oldRating: history[l]?.rating ?? 1500, acc: l + 1 }
}
)

Expand Down

0 comments on commit 70e5603

Please sign in to comment.