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
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user