feat(race-setup): list sessions in running order and move them with up/down (1.49.0)
This commit is contained in:
1 parent
e199f3aa1a
commit
bb0fa7ede4
14 files changed
+104
-14
No files matched your search
@@ -8,6 +8,16 @@ The application version is maintained in `package.json` and displayed in the adm
|
||||
|
||||
No changes recorded yet.
|
||||
|
||||
## 1.49.0 - 2026-11-01
|
||||
|
||||
### Added
|
||||
|
||||
- ▲▼ on each session in Race Setup move it earlier or later in the running order. Race Day's queue, ▶ Next and the series' next-step button follow it.
|
||||
|
||||
### Changed
|
||||
|
||||
- The session lists in Race Setup and on Race Day show the running order (practice, qualifying round by round, finals from the lowest) instead of the order the sessions were made in. A heat deleted and made again (e.g. Q1 H2) no longer ends up last.
|
||||
|
||||
## 1.48.0 - 2026-11-01
|
||||
|
||||
### Added
|
||||
|
||||
@@ -106,7 +106,7 @@ The menu follows how a race day works: **Start** (Dashboard, Race Day), **Create
|
||||
- **Quick actions** at the top: **Start practice** (continue or start an Open Practice), **New track layout** (during practice) and **Create race**. The Dashboard has the same three common tasks.
|
||||
- **A session picker** and the buttons that apply right now: Start, Pause, Resume, Finish, **↻ Run again** for a stopped or finished heat, qualifier or final (laps, results and clock reset), and for practice **Reset – new practice day**. Practice uses plain words and has no start lights. The picker lists today's races grouped per race (plus anything running); older races and other days' rounds are under **Show all sessions**.
|
||||
- **Live race** for the race controller, right under the clock while a heat, qualifier or final runs: the running order with laps, last lap, best lap, gap to the car ahead and to the leader, and the estimated finish (laps and time when the time is up). The heat's fastest lap is purple, a personal best on the last lap green, and a bar shows how far into the lap each car is (red = late). After the heat it shows the result.
|
||||
- The **heat queue** shows the current, next and after-next heat in running order: practice, qualifying round by round (Q1 H1, Q1 H2, Q2 H1 …), then finals from the lowest (C, B, A). When a heat is done, **▶ Next** selects the next one in one click.
|
||||
- The **heat queue** shows the current, next and after-next heat in running order: practice, qualifying round by round (Q1 H1, Q1 H2, Q2 H1 …), then finals from the lowest (C, B, A). When a heat is done, **▶ Next** selects the next one in one click. The session lists in Race Setup and on Race Day follow the same order, so a heat deleted and made again lands in its right place; **▲▼** on a session in Race Setup moves it earlier or later.
|
||||
- **Preflight** checks the decoder, participants, transponders (missing or duplicated), the lap window, the grid and audio. Blockers come first, each with a shortcut to the right setting. The min/max lap time can be edited right there.
|
||||
- **An automatic SQLite backup** is taken before every start.
|
||||
|
||||
|
||||
+1
-1
@@ -119,7 +119,7 @@ Gränssnittet finns på svenska och engelska.
|
||||
- **Snabbval** överst: **Starta träning** (fortsätt eller starta en Open Practice), **Ny banlayout** (under träning) och **Skapa race**. Översikten har samma tre vanliga uppgifter.
|
||||
- **En sessionsväljare** och de knappar som gäller just nu: Start, Pausa, Fortsätt, Avsluta, **↻ Kör om** för ett avbrutet eller klart heat, kval eller final (varv, resultat och klocka nollställs), och för träning **Nollställ – ny träningsdag**. Träning använder vanliga ord och har inga startljus. Väljaren visar dagens race grupperade per race (plus det som pågår); äldre race och andra dagars deltävlingar finns under **Visa alla sessioner**.
|
||||
- **Live-race** för race controllern, direkt under klockan medan ett heat, kval eller final pågår: ordningen med varv, senaste varv, bästa varv, avstånd till bilen före och till ledaren, och beräknat slut (varv och tid när tiden går ut). Heatets snabbaste varv är lila, personbästa på senaste varvet grönt, och en stapel visar hur långt in på varvet varje bil är (röd = sen). Efter heatet visas resultatet.
|
||||
- **Heat-kön** visar aktuellt, nästa och därpå följande heat i körordning: träning, kval omgång för omgång (Q1 H1, Q1 H2, Q2 H1 …), sedan finaler från lägsta (C, B, A). När ett heat är klart väljer **▶ Nästa** nästa heat med ett klick.
|
||||
- **Heat-kön** visar aktuellt, nästa och därpå följande heat i körordning: träning, kval omgång för omgång (Q1 H1, Q1 H2, Q2 H1 …), sedan finaler från lägsta (C, B, A). När ett heat är klart väljer **▶ Nästa** nästa heat med ett klick. Sessionslistorna i Race Setup och på Race Day följer samma ordning, så ett heat som tagits bort och skapats om hamnar på rätt plats; **▲▼** på en session i Race Setup flyttar den tidigare eller senare.
|
||||
- **Förkontrollen** kontrollerar decoder, deltagare, transpondrar (saknade eller dubbletter), varvtidsgränser, grid och ljud. Blockerare visas först, var och en med en genväg till rätt inställning. Min/max-varvtid kan ändras direkt där.
|
||||
- **En automatisk SQLite-backup** tas före varje start.
|
||||
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "rc-racecore",
|
||||
"version": "1.48.0",
|
||||
"version": "1.49.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "rc-racecore",
|
||||
"version": "1.48.0",
|
||||
"version": "1.49.0",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"better-sqlite3": "^12.11.1",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rc-racecore",
|
||||
"version": "1.48.0",
|
||||
"version": "1.49.0",
|
||||
"private": true,
|
||||
"description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence",
|
||||
"engines": {
|
||||
|
||||
+7
-3
@@ -641,7 +641,7 @@ const getSeriesRounds = (series) => state.events
|
||||
classDrivers: state.drivers.filter((driver) => driver.classId === event.classId).sort(byDriverName),
|
||||
participantIds: getEventDrivers(event).map((driver) => driver.id),
|
||||
status: getSeriesRoundStatus(sessions),
|
||||
nextStep: getSeriesRoundNextStep(sessions),
|
||||
nextStep: getSeriesRoundNextStep(sessions, event.sessionOrder),
|
||||
qualHeatCount: new Set(qualSessions.map((session) => String(session.name || "").split(" ").pop())).size,
|
||||
finalCount: sessions.filter((session) => session.type === "final").length,
|
||||
calculatedResult: getEventDayResult(event),
|
||||
@@ -1658,6 +1658,8 @@ const TRANSLATIONS = {
|
||||
"events.stagger_gap_sec": "Stagger-gap (sek)",
|
||||
"events.session_settings": "Sessioninställningar",
|
||||
"events.edit_session": "Inställningar",
|
||||
"events.move_session_up": "Kör tidigare (flytta upp i körordningen)",
|
||||
"events.move_session_down": "Kör senare (flytta ned i körordningen)",
|
||||
"events.start_mode_mass": "Mass-start",
|
||||
"events.start_mode_position": "Positionsstart",
|
||||
"events.start_mode_staggered": "Staggered / individuell start",
|
||||
@@ -2612,7 +2614,7 @@ const TRANSLATIONS = {
|
||||
"guide.race_day_title": "Race Day och säker start",
|
||||
"guide.card_race_day_blurb": "Förkontroll, startlista, heat-kö, automatisk backup och fokuserad racedrift.",
|
||||
"guide.race_day_1": "1. Skapa race och sessioner i Race Setup. Öppna sedan Race Day från gruppen Start.",
|
||||
"guide.race_day_2": "2. Välj aktuellt heat. Listan visar dagens race (Visa alla sessioner visar resten). Pågår, Nästa och Därefter följer körordningen: träning, kval omgång för omgång, finaler från lägsta. ▶ Nästa väljer nästa heat när ett är klart.",
|
||||
"guide.race_day_2": "2. Välj aktuellt heat. Listan visar dagens race (Visa alla sessioner visar resten). Pågår, Nästa och Därefter följer körordningen: träning, kval omgång för omgång, finaler från lägsta. ▶ Nästa väljer nästa heat när ett är klart. Ett heat som tagits bort och skapats om hamnar på rätt plats, och ▲▼ på sessionerna i Race Setup ändrar ordningen för hand.",
|
||||
"guide.race_day_3": "3. Förkontrollen visar blockerare först, sedan varningar och godkända kontroller. Knapparna vid problemen öppnar relevant meny; min/max kan rättas direkt i Race Day. Förkontrollen blockerar start när Main decoder är offline, deltagare eller transpondrar saknas, transpondrar är dubbla, varvfönstret är ogiltigt eller en positionsgrid är ofullständig.",
|
||||
"guide.race_day_4": "4. Gula kontroller är varningar. Valfria split-/depådecoders, backend och ljud visas tydligt men ändrar inte vanlig varvräkning.",
|
||||
"guide.race_day_5": "5. Vid start synkas state till backend och en konsistent SQLite-backup skapas i data/backups innan den befintliga audio- och starttonssekvensen körs. De 30 senaste sparas.",
|
||||
@@ -3553,6 +3555,8 @@ const TRANSLATIONS = {
|
||||
"events.stagger_gap_sec": "Stagger gap (sec)",
|
||||
"events.session_settings": "Session settings",
|
||||
"events.edit_session": "Settings",
|
||||
"events.move_session_up": "Run earlier (move up in the running order)",
|
||||
"events.move_session_down": "Run later (move down in the running order)",
|
||||
"events.start_mode_mass": "Mass start",
|
||||
"events.start_mode_position": "Position start",
|
||||
"events.start_mode_staggered": "Staggered / individual start",
|
||||
@@ -4507,7 +4511,7 @@ const TRANSLATIONS = {
|
||||
"guide.race_day_title": "Race Day and safe start",
|
||||
"guide.card_race_day_blurb": "Preflight, start list, heat queue, automatic backup, and focused race operation.",
|
||||
"guide.race_day_1": "1. Create the race and sessions in Race Setup, then open Race Day from the Start group.",
|
||||
"guide.race_day_2": "2. Select the current heat. The list shows today's races (Show all sessions shows the rest). Running, Next and After next follow the running order: practice, qualifying round by round, finals from the lowest. ▶ Next selects the next heat when one is done.",
|
||||
"guide.race_day_2": "2. Select the current heat. The list shows today's races (Show all sessions shows the rest). Running, Next and After next follow the running order: practice, qualifying round by round, finals from the lowest. ▶ Next selects the next heat when one is done. A heat deleted and made again lands in its right place, and ▲▼ on the sessions in Race Setup change the order by hand.",
|
||||
"guide.race_day_3": "3. Preflight lists blockers first, then warnings and passed checks. Buttons beside issues open the relevant menu; min/max can be corrected directly in Race Day. Preflight blocks start when the Main decoder is offline, participants or transponders are missing, transponders are duplicated, the lap window is invalid, or a position grid is incomplete.",
|
||||
"guide.race_day_4": "4. Yellow checks are warnings. Optional split/pit decoders, backend, and audio are visible but do not change normal lap counting.",
|
||||
"guide.race_day_5": "5. Starting synchronizes state to the backend and creates a consistent SQLite backup in data/backups before the existing audio and start-tone sequence runs. The latest 30 are retained.",
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { orderSessionsForRunning, moveSessionInRunningOrder } from "./event_race_logic.js";
|
||||
let activeManageTab = "setup";
|
||||
// Maps a data-target anchor id (used by the step-card overview and the race-summary
|
||||
// warning links) to the tab it now lives inside, so jumping to it also switches tabs
|
||||
@@ -117,7 +118,8 @@ export function renderEventManagerView(context) {
|
||||
}
|
||||
ensureRaceParticipantsConfigured(event);
|
||||
|
||||
const sessions = getSessionsForEvent(eventId);
|
||||
// Listed in running order; ▲▼ change it (stored on the event as sessionOrder).
|
||||
const sessions = orderSessionsForRunning(getSessionsForEvent(eventId), event.sessionOrder);
|
||||
const eventManageArea = document.getElementById("eventManageArea");
|
||||
if (!eventManageArea) {
|
||||
return;
|
||||
@@ -358,6 +360,12 @@ export function renderEventManagerView(context) {
|
||||
renderView();
|
||||
});
|
||||
|
||||
document.querySelectorAll(`[data-session-move="${s.id}"]`).forEach((button) => button.addEventListener("click", () => {
|
||||
event.sessionOrder = moveSessionInRunningOrder(sessions, event.sessionOrder, s.id, Number(button.dataset.step));
|
||||
saveState();
|
||||
refreshManager();
|
||||
}));
|
||||
|
||||
document.getElementById(`session-delete-${s.id}`)?.addEventListener("click", () => {
|
||||
state.sessions = state.sessions.filter((x) => x.id !== s.id);
|
||||
delete state.resultsBySession[s.id];
|
||||
|
||||
@@ -166,7 +166,7 @@ export function renderEventManagerMarkup(context) {
|
||||
<div class="mt-16">
|
||||
${renderTable(
|
||||
[t("table.session"), t("table.type"), t("table.duration"), t("table.start_mode"), t("table.seeding"), t("table.status"), t(event.mode === "track" ? "events.assignments" : "events.participants"), t("events.actions")],
|
||||
sessions.map((s) => {
|
||||
sessions.map((s, sessionIndex) => {
|
||||
const assignCount =
|
||||
event.mode === "track"
|
||||
? (s.assignments || []).length
|
||||
@@ -183,6 +183,8 @@ export function renderEventManagerMarkup(context) {
|
||||
<td>${escapeHtml(getStatusLabel(s.status))}</td>
|
||||
<td>${assignCount || (event.mode === "track" ? t("events.na") : "-")}</td>
|
||||
<td class="actions-inline">
|
||||
<button class="btn btn-mini" type="button" data-session-move="${escapeHtml(s.id)}" data-step="-1" title="${escapeHtml(t("events.move_session_up"))}" ${sessionIndex ? "" : "disabled"}>▲</button>
|
||||
<button class="btn btn-mini" type="button" data-session-move="${escapeHtml(s.id)}" data-step="1" title="${escapeHtml(t("events.move_session_down"))}" ${sessionIndex < sessions.length - 1 ? "" : "disabled"}>▼</button>
|
||||
<button id="session-edit-${s.id}" class="btn">${t("events.edit_session")}</button>
|
||||
<button id="session-active-${s.id}" class="btn">${t("events.set_active")}</button>
|
||||
${
|
||||
|
||||
+24
-1
@@ -768,7 +768,30 @@ export function generateQualifyingForRace(event, { buildPracticeStandings, getEv
|
||||
// The order a race's sessions are run in: practice, then qualifying round by round (Q1 H1,
|
||||
// Q1 H2, Q2 H1 ... - generation stores them heat by heat), then finals leg by leg with the
|
||||
// lowest final first (C1, B1, A1, C2 ...). Anything else keeps the order it was created in.
|
||||
export function orderSessionsForRunning(sessions = []) {
|
||||
// manualOrder (event.sessionOrder, set with ▲▼ in Race Setup) overrides it for the sessions it
|
||||
// lists; a session made later keeps its own place, e.g. a recreated Q1 H2 after Q1 H1.
|
||||
export function orderSessionsForRunning(sessions = [], manualOrder = []) {
|
||||
const auto = orderSessionsAutomatically(sessions);
|
||||
const byId = new Map(auto.map((session) => [session.id, session]));
|
||||
const listed = [...new Set(manualOrder || [])].filter((id) => byId.has(id)).map((id) => byId.get(id));
|
||||
if (!listed.length) return auto;
|
||||
const listedIds = new Set(listed.map((session) => session.id));
|
||||
let next = 0;
|
||||
return auto.map((session) => (listedIds.has(session.id) ? listed[next++] : session));
|
||||
}
|
||||
|
||||
// Moves one session a step up (-1) or down (+1) in the running order; returns the new manual
|
||||
// order (every session id) to store on the event.
|
||||
export function moveSessionInRunningOrder(sessions, manualOrder, sessionId, step) {
|
||||
const ids = orderSessionsForRunning(sessions, manualOrder).map((session) => session.id);
|
||||
const index = ids.indexOf(sessionId);
|
||||
const other = index + step;
|
||||
if (index < 0 || other < 0 || other >= ids.length) return ids;
|
||||
[ids[index], ids[other]] = [ids[other], ids[index]];
|
||||
return ids;
|
||||
}
|
||||
|
||||
function orderSessionsAutomatically(sessions = []) {
|
||||
const key = (session, index) => {
|
||||
if (["practice", "free_practice", "open_practice"].includes(session.type)) return [0, 0, 0, index];
|
||||
if (session.type === "qualification") {
|
||||
|
||||
@@ -43,7 +43,8 @@ export function buildRaceDayQueue(state) {
|
||||
return { current: null, next: null, afterNext: null, upcoming: [] };
|
||||
}
|
||||
|
||||
const eventSessions = orderSessionsForRunning(sessions.filter((session) => session.eventId === current.eventId));
|
||||
const event = (state.events || []).find((item) => item.id === current.eventId);
|
||||
const eventSessions = orderSessionsForRunning(sessions.filter((session) => session.eventId === current.eventId), event?.sessionOrder);
|
||||
const currentIndex = eventSessions.findIndex((session) => session.id === current.id);
|
||||
const upcoming = eventSessions
|
||||
.slice(Math.max(0, currentIndex + 1))
|
||||
|
||||
@@ -2,6 +2,7 @@ import { isPracticeSessionType } from "./track_layouts_logic.js";
|
||||
import { renderTrackLayoutBar, bindTrackLayoutBar } from "./track_layout_bar.js";
|
||||
import { PROLOGUE_OPTIONS_SEC, formatPrologueOption } from "./prologue_logic.js";
|
||||
import { estimateFinish } from "./timing_logic.js";
|
||||
import { orderSessionsForRunning } from "./event_race_logic.js";
|
||||
export function getRaceDayCheckAction(item, session) {
|
||||
if (item.level === "ok") return null;
|
||||
if (["backend", "decoder", "split_decoder", "pit_decoders", "audio"].includes(item.id)) {
|
||||
@@ -90,6 +91,8 @@ export function buildRaceDaySessionGroups({ sessions, events, selectedId = "", s
|
||||
if (!groups.has(session.eventId)) groups.set(session.eventId, { event: eventById.get(session.eventId) || null, sessions: [] });
|
||||
groups.get(session.eventId).sessions.push(session);
|
||||
});
|
||||
// Each race's sessions in running order (practice, Q1 H1, Q1 H2 ..., finals).
|
||||
groups.forEach((group) => { group.sessions = orderSessionsForRunning(group.sessions, group.event?.sessionOrder); });
|
||||
const list = [...groups.values()].sort((a, b) =>
|
||||
Number(b.sessions.some(isLive)) - Number(a.sessions.some(isLive))
|
||||
|| String(b.event?.date || "").localeCompare(String(a.event?.date || "")));
|
||||
|
||||
+2
-2
@@ -192,8 +192,8 @@ export function getSeriesRoundStatus(sessions = []) {
|
||||
// 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);
|
||||
export function getSeriesRoundNextStep(sessions = [], manualOrder = []) {
|
||||
const ordered = orderSessionsForRunning(sessions, manualOrder);
|
||||
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");
|
||||
|
||||
@@ -84,4 +84,27 @@ export async function runRaceSetupSmoke({ evaluate, navigate, fill, savedState,
|
||||
await click("team-delete-" + team.id);
|
||||
await waitFor(async () => !(await raceState()).raceConfig.teams.some(item => item.id === team.id), "team deletion");
|
||||
console.log("PASS race wizard/edit/reload, team create/member-edit/delete, session type/duration and lap limits");
|
||||
|
||||
// Running order: the sessions are listed in it, and ▲ moves one earlier.
|
||||
for (const name of ["Q1 H2", "Q1 H1"]) {
|
||||
await fill("sessionForm", { name, type: "qualification", durationMin: "5" });
|
||||
await submit("sessionForm");
|
||||
await waitFor(async () => (await savedState()).sessions.some((item) => item.name === name), name + " created");
|
||||
}
|
||||
const listed = async () => evaluate(`[...document.querySelectorAll("[data-session-move][data-step='1']")].map((button) => button.dataset.sessionMove)`);
|
||||
const sessionNames = async () => {
|
||||
const ids = await listed();
|
||||
const all = (await savedState()).sessions;
|
||||
return ids.map((id) => all.find((item) => item.id === id)?.name).filter((name) => /^Q1/.test(name));
|
||||
};
|
||||
await waitFor(async () => (await sessionNames()).join() === "Q1 H1,Q1 H2", "listed in running order although Q1 H1 was made last");
|
||||
const q12 = (await savedState()).sessions.find((item) => item.name === "Q1 H2");
|
||||
await evaluate(`document.querySelector('[data-session-move="${q12.id}"][data-step="-1"]').click()`);
|
||||
await waitFor(async () => (await sessionNames()).join() === "Q1 H2,Q1 H1", "Q1 H2 moved up");
|
||||
const q11 = (await savedState()).sessions.find((item) => item.name === "Q1 H1");
|
||||
await waitFor(async () => {
|
||||
const order = (await raceState()).sessionOrder || [];
|
||||
return order.includes(q12.id) && order.indexOf(q12.id) < order.indexOf(q11.id);
|
||||
}, "the order is saved on the race");
|
||||
console.log("PASS Race Setup lists sessions in running order and ▲▼ change it");
|
||||
}
|
||||
@@ -52,3 +52,19 @@ test("a round's hand-set result replaces the calculated one in the standings", a
|
||||
assert.deepEqual(getSeriesDayResult(series, "e1", calculated, (id) => names[id]).map((row) => row.driverName), ["Roy Gjemble", "Wilmer Nilsson"]);
|
||||
assert.equal(getSeriesDayResult(series, "e2", calculated), calculated, "no hand-set order: the calculated result");
|
||||
});
|
||||
|
||||
test("running order: a recreated heat keeps its place, and ▲▼ set an order of your own", async () => {
|
||||
const { moveSessionInRunningOrder } = await import("../src/event_race_logic.js");
|
||||
const s = (id, name, type = "qualification") => ({ id, name, type });
|
||||
// Q1 H2 was deleted and made again: it is last in the list but runs after Q1 H1.
|
||||
const sessions = [s("p", "Seeding practice", "practice"), s("q11", "Q1 H1"), s("q21", "Q2 H1"), s("q22", "Q2 H2"), s("a1", "A Final 1", "final"), s("q12", "Q1 H2")];
|
||||
const names = (list) => list.map((item) => item.name);
|
||||
assert.deepEqual(names(orderSessionsForRunning(sessions)), ["Seeding practice", "Q1 H1", "Q1 H2", "Q2 H1", "Q2 H2", "A Final 1"]);
|
||||
// Move Q2 H2 before Q2 H1.
|
||||
const manual = moveSessionInRunningOrder(sessions, [], "q22", -1);
|
||||
assert.deepEqual(names(orderSessionsForRunning(sessions, manual)), ["Seeding practice", "Q1 H1", "Q1 H2", "Q2 H2", "Q2 H1", "A Final 1"]);
|
||||
// A session made afterwards (not in the manual order) still gets its own place.
|
||||
const more = [...sessions, s("q31", "Q3 H1")];
|
||||
assert.deepEqual(names(orderSessionsForRunning(more, manual)), ["Seeding practice", "Q1 H1", "Q1 H2", "Q2 H2", "Q2 H1", "Q3 H1", "A Final 1"]);
|
||||
assert.deepEqual(moveSessionInRunningOrder(sessions, manual, "p", -1), manual, "the first can't move up");
|
||||
});
|
||||
Reference in new issue
Block a user