feat(series): next-step button per round and Race Day next session (1.44.0)
This commit is contained in:
1 parent
dbda06d101
commit
71aa149a4d
12 files changed
+145
-10
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { orderSessionsForRunning } from "./event_race_logic.js";
|
||||
// Series / cup: a set of races (events) scored together. Each event is one class, so a series
|
||||
// with several classes gives one standings table per class. Pure functions - app.js feeds
|
||||
// each event's day result (finishing order, from finals or else qualifying).
|
||||
@@ -162,3 +163,23 @@ export function getSeriesRoundStatus(sessions = []) {
|
||||
if (finished(quals)) return "qual_done";
|
||||
return started(quals) ? "qual_running" : "qual_ready";
|
||||
}
|
||||
|
||||
// The one thing to do next in a round, for the button on its row: run the seeding practice,
|
||||
// make qualifying, run the next heat, make finals, run the next final. A session already
|
||||
// running is shown first.
|
||||
export function getSeriesRoundNextStep(sessions = []) {
|
||||
const ordered = orderSessionsForRunning(sessions);
|
||||
const live = ordered.find((session) => ["running", "paused"].includes(session.status));
|
||||
if (live) return { kind: "live", session: live };
|
||||
const ready = (type) => ordered.find((session) => session.type === type && session.status === "ready");
|
||||
const has = (type) => ordered.some((session) => session.type === type);
|
||||
if (!has("qualification")) {
|
||||
const practice = ready("practice");
|
||||
return practice ? { kind: "seeding", session: practice } : { kind: "make_qualifying" };
|
||||
}
|
||||
const heat = ready("qualification");
|
||||
if (heat) return { kind: "qualifying", session: heat };
|
||||
if (!has("final")) return { kind: "make_finals" };
|
||||
const final = ready("final");
|
||||
return final ? { kind: "final", session: final } : { kind: "done" };
|
||||
}
|
||||
Reference in new issue
Block a user