fix(day): a heat already run between pending ones no longer gives every later heat the same time (1.89.16)

This commit is contained in:
larssand committed 2026-11-13 09:34:41 +01:00
1 parent 5b34317bcb
commit cb29c5471b
5 files changed
+30 -6

No files matched your search

+6
View File
@@ -8,6 +8,12 @@ The application version is maintained in `package.json` and displayed in the adm
No changes recorded yet.
## 1.89.16 - 2026-11-13
### Fixed
- Today's schedule: when classes take turns, a heat already run between heats still waiting no longer pulls the rest of the day back to "now" - upcoming heats got the same start time. They now follow one after the other again, and none is planned before the day's first start.
## 1.89.15
### Added
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "rc-racecore",
"version": "1.89.15",
"version": "1.89.16",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "rc-racecore",
"version": "1.89.15",
"version": "1.89.16",
"hasInstallScript": true,
"dependencies": {
"better-sqlite3": "^12.11.1",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "rc-racecore",
"version": "1.89.15",
"version": "1.89.16",
"private": true,
"description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence",
"engines": {
+8 -3
View File
@@ -123,7 +123,8 @@ export function moveInDayOrder(ordered, sessionId, step) {
// its first real start, else from now.
export function buildDaySchedule(ordered, day, now = Date.now()) {
const firstStart = ordered.map((session) => Number(session.startedAt || 0)).filter(Boolean).sort((a, b) => a - b)[0];
let cursor = Number(day?.startAt || 0) || firstStart || now;
const dayStartAt = Number(day?.startAt || 0) || 0;
let cursor = dayStartAt || firstStart || now;
let upcomingIndex = 0;
let previous = null;
const fixed = fixedBreakWindow(day);
@@ -152,11 +153,15 @@ export function buildDaySchedule(ordered, day, now = Date.now()) {
} else {
// A heat that would start or run into the fixed break (lunch) waits until it is over.
if (overlapsFixed(planned, durationMs)) { planned = fixed.end; afterFixedBreak = true; }
start = Math.max(planned, now);
// Not before the day's first start, nor before now.
start = Math.max(planned, now, dayStartAt);
if (overlapsFixed(start, durationMs)) { start = fixed.end; afterFixedBreak = true; }
end = start + durationMs;
}
cursor = end;
// A heat already run that comes after one still waiting (classes take turns, so a done
// heat of one class can follow a pending one of another) must not pull the cursor back
// to its real, earlier end - every heat after it would then get the same time ("now").
cursor = upcomingIndex > 0 || state === "upcoming" ? Math.max(cursor, end) : end;
return {
session,
breakMin,
+13
View File
@@ -157,3 +157,16 @@ test("the drivers' board shows the lunch while it is on, and before the heat aft
const before = renderDriverBoard({ t: (k) => k, escapeHtml: String, date: "2026-11-08", rows, getClassLabel: () => "2WD", getSessionGridEntries: () => [], getRemainingLabel: () => "", day, now: at("11:58") });
assert.doesNotMatch(before, /class="board-live board-break"/, "no lunch banner before lunch");
});
test("a heat already run between pending ones doesn't pull the rest of the day back to now", () => {
const T = (h) => new Date(`2026-11-12T${h}:00`).getTime();
const sessions = [
{ id: "p", type: "practice", name: "practice 1", status: "ready", durationMin: 5 },
{ id: "x", type: "practice", name: "other", status: "finished", durationMin: 5, startedAt: T("19:00"), endedAt: T("19:05") },
{ id: "q1", type: "qualification", name: "Q1 H1", status: "ready", durationMin: 5 },
{ id: "y", type: "qualification", name: "other q", status: "finished", durationMin: 5, startedAt: T("19:30"), endedAt: T("19:35") },
{ id: "q2", type: "qualification", name: "Q2 H1", status: "ready", durationMin: 5 },
];
const rows = buildDaySchedule(sessions, { startAt: T("23:40"), gapMin: 3 }, T("23:39")).filter((row) => row.state === "upcoming");
assert.deepEqual(rows.map((row) => row.start), [T("23:40"), T("23:48"), T("23:56")], "one after the other from the first start, not all at 23:39");
});