api/ui: per-lap cone entry for skidpad runs #94

Open
joaj wants to merge 1 commit from fix/skidpad-double-cones into master
Owner

Closes #3

A skidpad run is two laps (left + right circle), but the construct form collected a single run-level "Downed Cones" value which the API copied onto both lap rows. The run's cones therefore displayed twice in the lap table, and — worse — the cone time penalty was applied to both laps in scoring instead of only the lap where the cones were hit (avg of (t1+2N, t2+2N) instead of (t1+2N, t2)).

Fix: per-lap penalty entry

API (api/)

  • POST /lap/time_from_trigger_list accepts optional downed_cones_counts / off_courses_counts lists (index 0 = run_lap_index 1), validated to have one entry per lap of the run (400 on mismatch)
  • Run-level scalars keep their legacy behaviour for single-lap paths and non-updated clients

UI (ui/src/components/LapTimes.jsx)

  • Construct form shows Downed Cones (Left)/(Right) and Off Courses (Left)/(Right) inputs when a SKIDPAD event is selected, sending per-lap values
  • Other disciplines unchanged (single inputs, scalar payload)

Scoring (libs/scoring/)

  • No code change: total_cones already sums both laps' counts — it is now correct with distinct per-lap values; regression test added

Verified

  • 3 new API tests: per-lap values land on their own rows ([2, 1]), legacy scalar behaviour pinned, mismatch → 400
  • Scoring regression test: run total 2+1 = 3, not the duplicated 4
  • make check green; UI prettier/lint clean
  • Live stack: constructed a skidpad run through the running API — lap rows carry cones=2 / cones=1; the UI bundle contains the new fields
Closes #3 A skidpad run is two laps (left + right circle), but the construct form collected a single run-level "Downed Cones" value which the API copied onto **both** lap rows. The run's cones therefore displayed twice in the lap table, and — worse — the cone time penalty was applied to **both** laps in scoring instead of only the lap where the cones were hit (avg of `(t1+2N, t2+2N)` instead of `(t1+2N, t2)`). ## Fix: per-lap penalty entry **API** (`api/`) - `POST /lap/time_from_trigger_list` accepts optional `downed_cones_counts` / `off_courses_counts` lists (index 0 = `run_lap_index` 1), validated to have one entry per lap of the run (400 on mismatch) - Run-level scalars keep their legacy behaviour for single-lap paths and non-updated clients **UI** (`ui/src/components/LapTimes.jsx`) - Construct form shows **Downed Cones (Left)/(Right)** and **Off Courses (Left)/(Right)** inputs when a SKIDPAD event is selected, sending per-lap values - Other disciplines unchanged (single inputs, scalar payload) **Scoring** (`libs/scoring/`) - No code change: `total_cones` already sums both laps' counts — it is now correct with distinct per-lap values; regression test added ## Verified - 3 new API tests: per-lap values land on their own rows (`[2, 1]`), legacy scalar behaviour pinned, mismatch → 400 - Scoring regression test: run total `2+1 = 3`, not the duplicated `4` - `make check` green; UI prettier/lint clean - Live stack: constructed a skidpad run through the running API — lap rows carry `cones=2` / `cones=1`; the UI bundle contains the new fields
api/ui/scoring: per-lap cone entry for skidpad runs
All checks were successful
ci/woodpecker/pr/main Pipeline was successful
5ed0ed137c
A skidpad run is two laps (left/right circles), but the construct form
collected a single run-level "Downed Cones" value which the API copied
onto both lap rows. The run's cones therefore displayed twice in the
lap table (issue #3), and the time penalty applied to both laps instead
of only the lap where the cones were hit.

The insert endpoint now accepts optional per-lap downed_cones_counts /
off_courses_counts (index 0 = run_lap_index 1, validated against the
number of laps); the run-level scalars keep their legacy behaviour for
single-lap paths and old clients.

The UI construct form shows Left/Right inputs for skidpad events and
sends per-lap values; other disciplines are unchanged. Scoring's run
total is already the sum of both laps' counts and is now correct with
distinct values.
All checks were successful
ci/woodpecker/pr/main Pipeline was successful
Required
Details
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'fix/skidpad-double-cones:fix/skidpad-double-cones'
git switch 'fix/skidpad-double-cones'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
fspt/timekeeping!94
No description provided.