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 isFreePractice = sessionType === "free_practice";
|
||||||
const isOpenPractice = sessionType === "open_practice";
|
const isOpenPractice = sessionType === "open_practice";
|
||||||
const isRollingPractice = isFreePractice || isOpenPractice;
|
const isRollingPractice = isFreePractice || isOpenPractice;
|
||||||
|
const { maxLapMs } = getSessionLapWindow(session);
|
||||||
const nowTs = Date.now();
|
const nowTs = Date.now();
|
||||||
const rows = Object.values(result.competitors).map((row) => {
|
const rows = Object.values(result.competitors).map((row) => {
|
||||||
const allPassings = getCompetitorPassings(session, row, { includeInvalid: true });
|
const allPassings = getCompetitorPassings(session, row, { includeInvalid: true });
|
||||||
@@ -7115,10 +7116,18 @@ function buildLeaderboard(session) {
|
|||||||
? bestLapMs
|
? bestLapMs
|
||||||
: null;
|
: null;
|
||||||
const currentLapElapsedMs = lastPassingTs ? Math.max(0, nowTs - lastPassingTs) : 0;
|
const currentLapElapsedMs = lastPassingTs ? Math.max(0, nowTs - lastPassingTs) : 0;
|
||||||
const predictedRemainingMs = predictionBaseMs ? predictionBaseMs - currentLapElapsedMs : null;
|
const predictionStaleMs = predictionBaseMs
|
||||||
const predictedProgress = predictionBaseMs ? currentLapElapsedMs / predictionBaseMs : 0;
|
? 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 =
|
const predictionTone =
|
||||||
!predictionBaseMs || predictedProgress <= 0.85
|
!predictionActive || predictedProgress <= 0.85
|
||||||
? "good"
|
? "good"
|
||||||
: predictedProgress <= 1
|
: predictedProgress <= 1
|
||||||
? "warn"
|
? "warn"
|
||||||
|
|||||||
Reference in New Issue
Block a user