Fix CS2 Stage 3 QP slot assignment #89

Merged
chrisp merged 3 commits from claude/cs-results-qp-points-x7hums into main 2026-06-14 05:49:07 +00:00
Owner

Summary

  • 0-3 teams in Stage 3 were being assigned slots 9–10 (high QP) when marked eliminated before other Stage 3 teams, because computeStage3ExitQP filled from slot 9 upward using only the teams passed in
  • 1-3 teams had the same problem when marked before 2-3 teams
  • Fix: gate all Stage 3 QP computation on stage3Exits.length === STAGE3_TOTAL_EXITS (8) — partial saves write 0 QP as a placeholder, and correct QP/placements are assigned once all 8 exits are known
  • As belt-and-suspenders, computeStage3ExitQP now places 0-wins teams from the bottom of the slot range so the function itself is correct even if called with a partial set

Test plan

  • Run npm run test:run -- app/models/__tests__/cs2-major-stage.test.ts — all 17 tests pass
  • Mark 2 Stage 3 teams as 0-3 eliminated and save — confirm they show 0 QP (not 2 QP)
  • Mark all 8 Stage 3 exits and save — confirm 0-3 teams get slots 15–16 QP, 1-3 teams get slots 12–14 QP split correctly

🤖 Generated with Claude Code

## Summary - 0-3 teams in Stage 3 were being assigned slots 9–10 (high QP) when marked eliminated before other Stage 3 teams, because `computeStage3ExitQP` filled from slot 9 upward using only the teams passed in - 1-3 teams had the same problem when marked before 2-3 teams - Fix: gate all Stage 3 QP computation on `stage3Exits.length === STAGE3_TOTAL_EXITS` (8) — partial saves write 0 QP as a placeholder, and correct QP/placements are assigned once all 8 exits are known - As belt-and-suspenders, `computeStage3ExitQP` now places 0-wins teams from the bottom of the slot range so the function itself is correct even if called with a partial set ## Test plan - [ ] Run `npm run test:run -- app/models/__tests__/cs2-major-stage.test.ts` — all 17 tests pass - [ ] Mark 2 Stage 3 teams as 0-3 eliminated and save — confirm they show 0 QP (not 2 QP) - [ ] Mark all 8 Stage 3 exits and save — confirm 0-3 teams get slots 15–16 QP, 1-3 teams get slots 12–14 QP split correctly 🤖 Generated with [Claude Code](https://claude.com/claude-code)
chrisp added 3 commits 2026-06-14 05:12:19 +00:00
Stage Advancement UI now shows the full 16-team field for each stage
(direct entries plus teams that advanced from the previous stage),
so admins can see and mark eliminations for Stage 1 advancers competing
in Stage 2/3 without confusion about where those teams went.

Key changes:
- markCs2StageEliminations now accepts an explicit stageEliminated value
  per team, fixing a bug where Stage 1 teams eliminated in Stage 2 would
  have stageEliminated set to 1 (their entry stage) instead of 2.
- New assignCs2EliminationQP writes QP to event_results progressively
  as eliminations are saved: Stage 1/2 exits get 0 QP immediately,
  Stage 3 exits get sub-ranked QP (placements 9-16 by W-L record).
- Form keys changed to elim_{stageNum}_{participantId} so the backend
  knows which stage each elimination occurred at.
- Stage completion is inferred from saved data (≥8 eliminations at
  that stage) to automatically move advancers into the next section.
- STAGE_LABELS updated to reflect the real 16-team field for stages 2/3.

https://claude.ai/code/session_013u6vbGHdppe88wQ95BLANw
- Write placement in assignCs2EliminationQP so processQualifyingEvent
  preserves progressive QP at event finalization instead of zeroing it.
  Stage 1 exits get placement=25, Stage 2 exits get placement=17, Stage 3
  exits get their W-L group start slot (9-16) so tie-split logic re-derives
  the same averaged QP at finalization.
- Add clearCs2EliminationsAtStage model function and stage_displayed_{N}
  hidden fields so unchecking a team in the admin form actually clears
  their DB record (replacement semantics instead of additive).
- Add stageEliminated >= stageEntry validation in markCs2StageEliminations.
- Wrap mark-eliminations action handler in try/catch to surface errors.
- Switch serial recalculateParticipantQP loop to Promise.all.
- Remove duplicate calcStage3ExitQP from cs-major-simulator; import
  computeStage3ExitQP from cs2-major-stage and re-export under the
  original name so simulator tests remain unchanged.

https://claude.ai/code/session_013u6vbGHdppe88wQ95BLANw
Fix CS2 Stage 3 QP: 0-3 teams always slot to bottom, defer all QP until all 8 exits known
All checks were successful
🚀 Deploy / 🧪 Test (pull_request) Successful in 3m0s
🚀 Deploy / ʦ🔍 Typecheck & Lint (pull_request) Successful in 1m23s
🚀 Deploy / 🐳 Build (pull_request) Has been skipped
🚀 Deploy / 🚀 Deploy (pull_request) Has been skipped
e2cf299204
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
chrisp merged commit d0a31f3883 into main 2026-06-14 05:49:07 +00:00
Sign in to join this conversation.
No description provided.