diff --git a/ROADMAP.md b/ROADMAP.md index 8f5d8e1..6f17eeb 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -982,7 +982,72 @@ Asked for after the first ÖRC Winter round, where a qualifying went wrong and t - [ ] **CSV export for a whole race day.** Pick a date and a class (or all classes). One row per lap from every session that day: class, session (in running order), driver, transponder, lap number, lap time, time of day, plus a session summary (position, laps, total time, best lap, average). Frontend only: reuse `buildLeaderboard`, `orderSessionsForRunning` and the existing file download helper; no server or schema change. Button in the Results archive when filtered on a date, with a shortcut on the series round. - [ ] **Readable day PDF per class (optional, after the CSV).** The day result used for series points (manual ✎ Result if set), then every session in running order with its full result. Lap-by-lap times stay in the CSV. -- [ ] **Publish to an external results site (e.g. House of RC).** Create the race / series there over its API and push the results (and optionally laps) after each session or at the end of the day, so the club's racing gets more exposure. Open questions before building: is there a public API and how is it authenticated (club account / API key stored in Settings), what format it expects (class, heats, qualifying, finals, points), whether it can be updated afterwards when a result is corrected by hand, and what happens when the club PC is offline (queue and retry). Start by investigating the API; keep the integration as a separate server module so a different site can be added later. +- [ ] **Publish to an external results site (e.g. House of RC).** Planned in detail in [House of RC integration](#house-of-rc-integration-entries-in-results-out-planned-2026-11-07) below. + +## House of RC integration: entries in, results out (planned 2026-11-07) + +Goal: in RaceCore, pick a House of RC event, fetch its entries, create the race in one click, run it, and post the results back. Drivers should only have to sign up in one place. + +What we know (checked 2026-11-07): +- No public API is documented. `/api`, `/api/v1/events/`, `/developers` and `/docs/api` all return 404. The only endpoint seen is the site's own `/api/stats/brands?event_id=`, which uses a per-page `api_token` and is not meant for us. +- Each event carries `"timing_id": "everlaps"` (or LiveTime) and an `external_id`. House of RC already imports results from timing systems, so the natural route is for RaceCore to become one of those sources. +- Conclusion: phase 0 needs House of RC's cooperation. Scraping the site is not an option, because it is fragile and probably against their terms. + +### Phase 0 - agreement with House of RC (blocking) +- [ ] Contact House of RC. Ask for: + - API access for clubs, and how it is authenticated (API key per club, or OAuth); + - a test or sandbox event; + - rate limits; + - whether `racecore` can be added as a `timing_id`. +- [ ] Get the formats in writing: + - entry fields (name, class, transponder, club, country, entry ID, status paid/withdrawn); + - result structure (qualifying, finals with legs, heats, laps, points); + - whether a result can be overwritten after a correction. +- [ ] Fallback if there is no API: find out which file they import from Everlaps or LiveTime and produce the same format, so it can be uploaded by hand. + +### Phase 1 - connection (server module + Settings) +- [ ] `server/integrations/houseofrc.js`, a separate module so other sites (MyRCM and others) can be added later. +- [ ] The server talks to House of RC, never the browser. This keeps the API key away from the client and avoids CORS. The key is stored server-side and is never included in exports or JSON packages. +- [ ] Settings → System: an "Integrations" panel with the API key, a club/organiser ID and a **Test connection** button. Saving requires the admin PIN if one is set. +- [ ] Routes: `GET /api/integrations/houseofrc/events`, `GET .../events/:id/entries`, `POST .../events/:id/results`. + +### Phase 2 - fetch entries (GET) +- [ ] Race Setup → "Fetch from House of RC": a list of the club's upcoming events, then pick an event and its classes. +- [ ] A preview before anything is saved: + - entries are matched to existing drivers by transponder, then by name; + - each entry is marked new, existing or conflicting (same transponder on another driver); + - their classes are mapped to RaceCore classes, and the mapping is remembered; + - Rookie entries can point to a driver in another class. +- [ ] `externalRefs.houseofrc = { eventId, entryId }` is stored on drivers and events, which makes re-fetching and publishing idempotent. +- [ ] Only the data needed for timing is stored (name, class, transponder, club). Contact details are not stored (GDPR). + +### Phase 3 - create the race in one click +- [ ] "Create race" uses the existing wizard and series code (`participantsConfigured` + `driverIds`, format presets, `createSeriesEvents`). It makes one race per class. If the event belongs to a series, the race lands as a round of that series. +- [ ] **Re-fetch** for late entries and withdrawals shows a diff (+added / −withdrawn). Changes only reach heats that have not started, which works the same way as editing participants today. + +### Phase 4 - publish results (POST) +- [ ] Mapping (`src/houseofrc_mapping.js`, pure and unit-tested). It covers: + - qualifying standings; + - finals with Qual/TQ, legs and A/B/C; + - each heat's result; + - best lap; + - optionally the laps. + - Judging corrections and manual ✎ results are included. +- [ ] Publishing works two ways: a **Publish** button on the race overview and the series round, and an optional automatic publish after each finished session. +- [ ] Idempotent: results are sent as an upsert keyed by the external ID, so a later correction in Judging re-publishes the same result instead of duplicating it. +- [ ] An offline queue as a new SQLite table `integration_outbox`: + - columns: event, payload, attempts, last error, sent at; + - retried while the club PC is offline; + - the status (✔ published / ⏳ queued / ⚠ failed with reason) is shown with the same pattern as the connection status. + +### Phase 5 - tests and documentation +- [ ] A mock House of RC server in the tests (on its own port, like `npm test`). It covers: + - fetching, matching, creating, re-fetching and publishing; + - the offline queue with a retry. +- [ ] A browser test: fetch → create race → run a heat → publish. +- [ ] Guide tab and both READMEs: "Fetch entries and publish to House of RC". + +Open questions to settle in phase 0: does House of RC handle payments and fees, and should RaceCore show the paid status? Should laps be published, or only results? Can a club publish to someone else's event (organiser vs. timing club)? ## Race day schedule, autopilot and drivers' board (2026-11-01)