brackt/app/models
Chris Parsons b81089879c
Fix while_on autodraft stalling between chain bursts, fixes #190 (#222)
The chain (checkAndTriggerNextAutodraft) picks consecutive while_on teams
immediately after a pick, but is capped at totalTeams iterations. Once the
cap is hit, the next while_on team had to wait for the full timer countdown
before their pick fired — which users experienced as autodraft intermittently
not working.

Root cause fix: the timer loop now detects while_on mode and triggers the
pick immediately (≤1 s) regardless of time remaining, bypassing the
countdown. A timer-update with timeRemaining:0 is emitted first so clients
don't see a frozen timer. If the chain already handled the pick, executeAutoPick
returns "Pick already made" and the timer moves on harmlessly.

Additional fixes:
- Add timerTickRunning guard so concurrent setInterval ticks (when a chain
  takes >1 s) don't race on the same pick slot
- Use onConflictDoNothing on the draft pick INSERT in executeAutoPick so a
  DB unique-constraint collision is treated as "Pick already made" rather
  than pausing the draft
- Cache draftSlots per season in the timer loop (slots never change during
  an active draft) — eliminates one DB query per tick
- currentPickNumber || 1 → ?? 1

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-24 19:09:38 -07:00
..
__tests__ Fix while_on autodraft stalling between chain bursts, fixes #190 (#222) 2026-03-24 19:09:38 -07:00
commissioner.ts Grant sitewide admins commissioner-level access in leagues (#162) 2026-03-18 00:41:56 -07:00
draft-pick.ts Fix oxlint warnings: no-shadow, consistent-function-scoping, no-non-null-assertion, and others (#196) 2026-03-21 10:59:51 -07:00
draft-queue.ts feat: proactively prune ineligible queue items after each pick (#59) 2026-03-02 22:07:22 -08:00
draft-slot.ts Simplify team breakdown page layout and fix code quality issues (#155) 2026-03-17 09:20:41 -07:00
draft-timer.ts Fix draft timer creation for teams without existing timers (#26) 2026-02-22 17:27:16 -08:00
draft-utils.ts Fix while_on autodraft stalling between chain bursts, fixes #190 (#222) 2026-03-24 19:09:38 -07:00
ev-snapshot.ts User/chris/ev f1 framework (#93) 2026-03-09 15:34:31 -07:00
event-result.ts feat: Add scoring event and results management with comprehensive scoring rules and standings tracking 2025-10-28 23:50:50 -07:00
index.ts feat: add draft pick, queue, and timer models with database schema updates 2025-10-16 00:32:48 -07:00
league.ts Add oxlint linting setup with zero errors (#194) 2026-03-21 09:44:05 -07:00
participant-expected-value.ts Add snooker bracket simulator and Elo ratings admin UI, fixes #119 2026-03-23 08:24:28 -07:00
participant-result.ts Add oxlint linting setup with zero errors (#194) 2026-03-21 09:44:05 -07:00
participant-season-result.ts Add oxlint linting setup with zero errors (#194) 2026-03-21 09:44:05 -07:00
participant.ts Add Zod validation and expand export/import for EV and results data (#14) 2026-02-20 20:25:25 -08:00
pending-standings-mappings.ts Add regular season standings for NBA/NHL (fixes #89) (#192) 2026-03-21 00:12:01 -07:00
playoff-match-game.ts Add playoff match game scheduling and odds management (#135) 2026-03-11 14:17:43 -07:00
playoff-match-odds.ts Add playoff match game scheduling and odds management (#135) 2026-03-11 14:17:43 -07:00
playoff-match.ts Fix oxlint warnings: no-shadow, consistent-function-scoping, no-non-null-assertion, and others (#196) 2026-03-21 10:59:51 -07:00
qualifying-points.ts Fix oxlint warnings: no-shadow, consistent-function-scoping, no-non-null-assertion, and others (#196) 2026-03-21 10:59:51 -07:00
regular-season-standings.ts Fix standings upsert no-op: use EXCLUDED pseudo-table (#215) 2026-03-23 21:22:53 -07:00
scoring-calculator.ts Replace console.* with structured logger, fix no-inferrable-types (closes #98) (#199) 2026-03-21 13:41:39 -07:00
scoring-event.ts Don't show Game #1 label for single-game matchups in calendar (#206) 2026-03-22 16:39:26 -07:00
scoring-rules.ts Fix partial bracket scoring, rank labels, and Discord notification bugs (#158) 2026-03-17 12:34:10 -07:00
season-sport.ts feat: Refactor database connection handling in draft-related functions for improved flexibility 2025-10-26 20:35:55 -07:00
season-template-sport.ts refactor: remove isRequired field from season sports and templates 2025-10-13 15:00:59 -07:00
season-template.ts feat: add sports and participant models with admin user functionality 2025-10-12 21:16:00 -07:00
season.ts Add isDraftable toggle to sport seasons (#165) (#178) 2026-03-18 22:40:19 -07:00
sport.ts Fix oxlint warnings: no-shadow, consistent-function-scoping, no-non-null-assertion, and others (#196) 2026-03-21 10:59:51 -07:00
sports-season.ts Fix oxlint warnings: no-shadow, consistent-function-scoping, no-non-null-assertion, and others (#196) 2026-03-21 10:59:51 -07:00
standings.ts Redesign standings page with sortable table, 7-day change, and chart repositioned (#205) 2026-03-22 11:05:13 -07:00
surface-elo.ts Add tennis Grand Slam simulator with surface Elo ratings, fixes #116 (#216) 2026-03-23 23:59:35 -07:00
team.ts Auto-name teams on claim and harden owner-assignment logic (#163) 2026-03-18 00:53:40 -07:00
tournament-group.ts Add oxlint linting setup with zero errors (#194) 2026-03-21 09:44:05 -07:00
user.ts Optimize user data fetching with batch queries and centralize display name logic (#176) 2026-03-18 16:46:07 -07:00