Skip to content

Commit d33c1c7

Browse files
committed
fix(ranking): 如果还没 AK 则排名还有可能发生变化
1 parent 6ac0008 commit d33c1c7

File tree

1 file changed

+35
-5
lines changed

1 file changed

+35
-5
lines changed

src/content/pages/ranking/rankSlice.ts

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,12 @@ const setRealPredict = (
263263
key: string,
264264
score: number,
265265
finishTime: number,
266-
previous: Previous
266+
previous: Previous,
267+
totalScore: number
267268
) => {
268269
const { oldRating, acc, preCache } = realPredict[key] ?? {}
269270
const { RatingData, seeds, lastTime } = previous
271+
console.log(totalScore, lastTime)
270272
if (RatingData && seeds && oldRating !== undefined) {
271273
const rank = findRank(RatingData, score, finishTime)
272274
const cache = rank * 1e4 + oldRating!
@@ -276,7 +278,8 @@ const setRealPredict = (
276278
realPredict[key].delta = delta
277279
realPredict[key].preCache = cache
278280
realPredict[key].erank = getERank(seeds, oldRating)
279-
realPredict[key].isStable = finishTime <= lastTime!
281+
realPredict[key].isStable =
282+
score === totalScore && finishTime <= lastTime!
280283
}
281284
}
282285
}
@@ -311,7 +314,10 @@ export const contestInfosSlice = createSlice({
311314
const { contestSlug, key } = action.payload
312315
const { realPredict, users, previous } = state[contestSlug]
313316
const { score, finishTime } = users[key]
314-
setRealPredict(realPredict, key, score, finishTime, previous)
317+
const totalScore =
318+
state[contestSlug].info?.questions.reduce((a, b) => a + b.credit, 0) ??
319+
Infinity
320+
setRealPredict(realPredict, key, score, finishTime, previous, totalScore)
315321
},
316322
},
317323
extraReducers(builder) {
@@ -374,7 +380,19 @@ export const contestInfosSlice = createSlice({
374380
)) {
375381
const key = gkey(region, username)
376382
if (!realPredict[key]) continue
377-
setRealPredict(realPredict, key, score, finishTime, previous)
383+
const totalScore =
384+
state[contestSlug].info?.questions.reduce(
385+
(a, b) => a + b.credit,
386+
0
387+
) ?? Infinity
388+
setRealPredict(
389+
realPredict,
390+
key,
391+
score,
392+
finishTime,
393+
previous,
394+
totalScore
395+
)
378396
}
379397

380398
previous.status = 'succeeded'
@@ -439,7 +457,19 @@ export const contestInfosSlice = createSlice({
439457
submission: submissions[i],
440458
}
441459
}
442-
setRealPredict(realPredict, key, score, finishTime, previous)
460+
const totalScore =
461+
state[contestSlug].info?.questions.reduce(
462+
(a, b) => a + b.credit,
463+
0
464+
) ?? Infinity
465+
setRealPredict(
466+
realPredict,
467+
key,
468+
score,
469+
finishTime,
470+
previous,
471+
totalScore
472+
)
443473
}
444474
state[contestSlug].fetchContestRankingState = 'succeeded'
445475
})

0 commit comments

Comments
 (0)