brackt/app/routes/api
Chris Parsons 16aa450d63
feat: proactively prune ineligible queue items after each pick (#59)
After every pick, recalculate draft eligibility for all teams and
remove any queued participants whose sport is no longer eligible
(e.g. a team queued a snooker player but just filled their last flex
slot). Previously this was only caught lazily when autodraft fired,
which could pause the draft or pick an unwanted player.

- Add getAllQueuesForSeason to draft-queue.ts — fetches all queue rows
  for a season in one query (Map<teamId, QueueItem[]>) instead of N+1
  per-team queries
- Add pruneIneligibleQueueItems to draft-utils.ts — uses Promise.all
  for the four required data fetches, collects ineligible items in a
  single loop pass, warns on orphaned participant references
- Call from both pick paths: executeAutoPick and draft.make-pick.ts
- Emit queue-eligibility-pruned socket event per affected team so the
  client updates the queue UI in real time
- Add 5 tests covering: single ineligible removal, all eligible (no-op),
  empty queues (no delete called, getTeamQueue never called), mixed
  queue (only ineligible item removed), and unknown participant (warn)

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-02 22:07:22 -08:00
..
__tests__ fix: harden draft timer system with race-condition safety and DRY refactor (#34) 2026-02-23 23:23:24 -08:00
webhooks refactor: simplify user update logic in Clerk webhook handler to reuse findOrCreateUser 2025-10-14 21:50:07 -07:00
autodraft.update.ts Claude/redesign autodraft queue c4 kp r (#40) 2026-02-27 22:16:26 -08:00
draft.adjust-time-bank.ts Claude/fix pick timer ghll n (#29) 2026-02-22 19:29:29 -08:00
draft.force-autopick.ts Claude/fix pick timer ghll n (#29) 2026-02-22 19:29:29 -08:00
draft.force-manual-pick.ts fix: harden draft timer system with race-condition safety and DRY refactor (#34) 2026-02-23 23:23:24 -08:00
draft.make-pick.ts feat: proactively prune ineligible queue items after each pick (#59) 2026-03-02 22:07:22 -08:00
draft.pause.ts Claude/fix pick timer ghll n (#29) 2026-02-22 19:29:29 -08:00
draft.replace-pick.ts Claude/fix pick timer ghll n (#29) 2026-02-22 19:29:29 -08:00
draft.resume.ts Claude/fix pick timer ghll n (#29) 2026-02-22 19:29:29 -08:00
draft.rollback.ts Claude/fix pick timer ghll n (#29) 2026-02-22 19:29:29 -08:00
draft.start.ts fix: harden draft timer system with race-condition safety and DRY refactor (#34) 2026-02-23 23:23:24 -08:00
queue.add.ts Claude/fix pick timer ghll n (#29) 2026-02-22 19:29:29 -08:00
queue.clear.ts Claude/fix pick timer ghll n (#29) 2026-02-22 19:29:29 -08:00
queue.remove.ts Claude/fix pick timer ghll n (#29) 2026-02-22 19:29:29 -08:00
queue.reorder.ts Claude/fix pick timer ghll n (#29) 2026-02-22 19:29:29 -08:00
seasons.$seasonId.draft.ts feat: add public read-only draft state API endpoint (#52) 2026-03-02 00:35:23 -08:00