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:
1 parent
5b34317bcb
commit
cb29c5471b
5 files changed
+30
-6
No files matched your search
@@ -8,6 +8,12 @@ The application version is maintained in `package.json` and displayed in the adm
|
|||||||
|
|
||||||
No changes recorded yet.
|
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
|
## 1.89.15
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "rc-racecore",
|
"name": "rc-racecore",
|
||||||
"version": "1.89.15",
|
"version": "1.89.16",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "rc-racecore",
|
"name": "rc-racecore",
|
||||||
"version": "1.89.15",
|
"version": "1.89.16",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"better-sqlite3": "^12.11.1",
|
"better-sqlite3": "^12.11.1",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "rc-racecore",
|
"name": "rc-racecore",
|
||||||
"version": "1.89.15",
|
"version": "1.89.16",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence",
|
"description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence",
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
@@ -123,7 +123,8 @@ export function moveInDayOrder(ordered, sessionId, step) {
|
|||||||
// its first real start, else from now.
|
// its first real start, else from now.
|
||||||
export function buildDaySchedule(ordered, day, now = Date.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];
|
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 upcomingIndex = 0;
|
||||||
let previous = null;
|
let previous = null;
|
||||||
const fixed = fixedBreakWindow(day);
|
const fixed = fixedBreakWindow(day);
|
||||||
@@ -152,11 +153,15 @@ export function buildDaySchedule(ordered, day, now = Date.now()) {
|
|||||||
} else {
|
} else {
|
||||||
// A heat that would start or run into the fixed break (lunch) waits until it is over.
|
// 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; }
|
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; }
|
if (overlapsFixed(start, durationMs)) { start = fixed.end; afterFixedBreak = true; }
|
||||||
end = start + durationMs;
|
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 {
|
return {
|
||||||
session,
|
session,
|
||||||
breakMin,
|
breakMin,
|
||||||
|
|||||||
@@ -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") });
|
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");
|
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");
|
||||||
|
});
|
||||||
Reference in new issue
Block a user