"Plukket opp" — a new button in the scoring wizard's Slag step (only for Slagspill/Stableford, when handicap is known). Tapping it auto-hops forward just like picking a stroke count, and the server writes the exact Net Double Bogey score (par+2+mottatte slag) — so it flows through the existing HCP/AGS pipeline unchanged, always nets to exactly 0 Stableford points. Shown everywhere as a "PU" badge instead of a raw number: scorekortet, leaderboardet, "Så langt i runden". Along the way, browser testing caught two real bugs (not just theoretical): the new-round form briefly showed a nonsensical "set up sides" notice under Stableford, and — more seriously — the match/skins territory-bar panel was rendering empty "Side A/Side B" bars on a Stableford round. Both traced to the same root cause (=== "stroke" checks that needed to also exclude the new format), and a full grep caught three more of the same pattern in watch-round.tsx before they could reach production. Everything verified in scratch (hand-calculated math matched exactly) and in the browser (all four display surfaces, plus a regression check on an existing match round). Migration 038 applied to the real database, both containers redeployed, teeoff.no unaffected.
29 lines
1.8 KiB
SQL
29 lines
1.8 KiB
SQL
-- =====================================================================
|
|
-- TeeCup — Stableford som egen spilleform + "plukket opp"-tilstand,
|
|
-- migrasjon 038. FEATURE_BACKLOG.md sitt eget notat fra 2026-07-25:
|
|
-- frittstående runder hadde ingen faktisk Stableford-FORMAT (kun rå
|
|
-- slagtall), og ingen vei til å registrere at en spiller plukket opp
|
|
-- ballen fordi hullet uansett var klart 0 poeng.
|
|
--
|
|
-- Stableford-POENGENE var allerede beregnet og vist flere steder (rund-
|
|
-- detail.tsx/round-scorecard.tsx/round-leaderboard.tsx sin stablefordPoints()
|
|
-- /total_points) -- denne migrasjonen dekker de to reelt manglende bitene:
|
|
-- (1) 'stableford' som et faktisk selvdeklarert play_format, side om side
|
|
-- med 'stroke'/'match' (samme individuelle, ikke-to-sidede kategori som
|
|
-- 'stroke' -- IKKE i _TWO_SIDED_FORMATS), (2) round_hole.picked_up.
|
|
--
|
|
-- "Plukket opp" lagres IKKE som en NULL-score -- den skrives eksplisitt
|
|
-- som Net Double Bogey (par + 2 + mottatte slag), samme cap som
|
|
-- handicap_engine.py sin max_hole_score_for_handicap() ALLEREDE bruker
|
|
-- for enhver høy score (Rule 3.1b). Dette gir automatisk nøyaktig 0
|
|
-- Stableford-poeng (samme formel som ellers) OG et korrekt AGS-bidrag
|
|
-- for faktisk-HCP (ADR-038) -- ingen ny motorlogikk trengs, kun et nytt
|
|
-- felt for VISNING ("Plukket opp" i stedet for et rått slagtall).
|
|
-- =====================================================================
|
|
\set ON_ERROR_STOP on
|
|
|
|
ALTER TABLE round_hole ADD COLUMN picked_up boolean NOT NULL DEFAULT false;
|
|
|
|
ALTER TABLE round DROP CONSTRAINT round_play_format_check;
|
|
ALTER TABLE round ADD CONSTRAINT round_play_format_check
|
|
CHECK (play_format IN ('stroke', 'match', 'skins', 'fourball', 'foursome', 'greensome', 'scramble_2', 'scramble_4', 'stableford'));
|