Phase A: external HTTP cron jobs for snapshots, standings sync, and simulation #79

Merged
chrisp merged 3 commits from feat/phase-a-cron-jobs into main 2026-06-08 07:42:15 +00:00

3 commits

Author SHA1 Message Date
Chris Parsons
52eb3abac1 Fix three code review findings from Phase A cron jobs
All checks were successful
🚀 Deploy / 🧪 Test (pull_request) Successful in 2m45s
🚀 Deploy / ʦ🔍 Typecheck & Lint (pull_request) Successful in 1m29s
🚀 Deploy / 🐳 Build (pull_request) Has been skipped
🚀 Deploy / 🚀 Deploy (pull_request) Has been skipped
- Remove `| cat` from both Forgejo workflow curl commands so HTTP 4xx/5xx
  causes the step to fail (bash pipeline exit code was always 0 via cat)
- Simplify sync-and-simulate: drop redundant pre-check DB query for
  standingsLastChangedAt; changed===true already means standings updated
  this run, so always simulate (runner's simulationStatus guard handles overlap)
- Delete server/snapshots.ts — all exports were orphaned after startSnapshotSystem
  was removed from server/socket.ts in the Phase A commit

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 00:35:02 -07:00
Chris Parsons
bfe2350f45 Document CRON_SECRET in .env.example
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 00:25:31 -07:00
Chris Parsons
85bfc657e5 Add Phase A: external HTTP cron jobs for snapshots, standings sync, and simulation
- Add POST /admin/jobs/run-daily-snapshots (replaces 24h setInterval in server/snapshots.ts)
- Add POST /admin/jobs/sync-and-simulate (syncs standings every 2h; only simulates when standings
  actually changed by comparing gamesPlayed + leagueRank before upserting)
- Add standingsLastChangedAt + lastSimulatedAt columns to sportsSeasons (migration 0118)
- Add GET /healthz route for Docker healthcheck (pings DB, returns 503 on failure)
- Add app/lib/cron-auth.ts shared X-Cron-Secret header auth helper
- Remove startSnapshotSystem() from server/socket.ts (no more in-process setInterval)
- Add Forgejo Actions scheduled workflows: daily-snapshots.yml (00:05 UTC) and
  sync-and-simulate.yml (every 2h) — require CRON_SECRET repo secret

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 00:18:41 -07:00