Clamp stale next-lap prediction
This commit is contained in:
15
src/app.js
15
src/app.js
@@ -7088,6 +7088,7 @@ function buildLeaderboard(session) {
|
||||
const isFreePractice = sessionType === "free_practice";
|
||||
const isOpenPractice = sessionType === "open_practice";
|
||||
const isRollingPractice = isFreePractice || isOpenPractice;
|
||||
const { maxLapMs } = getSessionLapWindow(session);
|
||||
const nowTs = Date.now();
|
||||
const rows = Object.values(result.competitors).map((row) => {
|
||||
const allPassings = getCompetitorPassings(session, row, { includeInvalid: true });
|
||||
@@ -7115,10 +7116,18 @@ function buildLeaderboard(session) {
|
||||
? bestLapMs
|
||||
: null;
|
||||
const currentLapElapsedMs = lastPassingTs ? Math.max(0, nowTs - lastPassingTs) : 0;
|
||||
const predictedRemainingMs = predictionBaseMs ? predictionBaseMs - currentLapElapsedMs : null;
|
||||
const predictedProgress = predictionBaseMs ? currentLapElapsedMs / predictionBaseMs : 0;
|
||||
const predictionStaleMs = predictionBaseMs
|
||||
? Math.max(
|
||||
predictionBaseMs * 2,
|
||||
Number.isFinite(maxLapMs) && maxLapMs > 0 ? maxLapMs : 0,
|
||||
15000
|
||||
)
|
||||
: 0;
|
||||
const predictionActive = Boolean(predictionBaseMs && lastPassingTs && currentLapElapsedMs <= predictionStaleMs);
|
||||
const predictedRemainingMs = predictionActive ? predictionBaseMs - currentLapElapsedMs : null;
|
||||
const predictedProgress = predictionActive ? currentLapElapsedMs / predictionBaseMs : 0;
|
||||
const predictionTone =
|
||||
!predictionBaseMs || predictedProgress <= 0.85
|
||||
!predictionActive || predictedProgress <= 0.85
|
||||
? "good"
|
||||
: predictedProgress <= 1
|
||||
? "warn"
|
||||
|
||||
Reference in New Issue
Block a user