Skip to content

Add live results feed that auto-updates scores at startup#17

Merged
ChristianAbele02 merged 2 commits into
mainfrom
feature/flags-and-pack-estimate
Jun 21, 2026
Merged

Add live results feed that auto-updates scores at startup#17
ChristianAbele02 merged 2 commits into
mainfrom
feature/flags-and-pack-estimate

Conversation

@ChristianAbele02

@ChristianAbele02 ChristianAbele02 commented Jun 21, 2026

Copy link
Copy Markdown
Owner

A new feed (services/resultsFeed.ts) pulls the latest played scores from the public openfootball dataset (CC0) every time the server boots — in the background, so a slow or offline network never delays startup. Elo ratings, win/draw/win predictions, group standings and the Monte Carlo simulator are all derived from match_results on each request, so they update live as games are played, with no regenerate or redeploy.

  • Result provenance: match_results gains a source column (feed vs user, via an idempotent migration). The feed only ever writes/overwrites its own feed rows, so any score you edit in-app (user) is never clobbered.
  • Manual refresh: POST /api/results/refresh and a "Refresh results now" button in Settings pull newly-played games on demand (reports added/updated/unchanged).
  • Shared parser (lib/openfootball.ts) is now used by both the build-time generator and the runtime feed, so the team map and score parsing can't drift (generator output verified byte-identical after the refactor).
  • Config: LIVE_RESULTS=off disables it; RESULTS_FEED_CUP_URL / _FINALS_URL / _TIMEOUT_MS override the source.
  • Refreshed the bundled dataset to 36 played games (only scores changed).

Tests: +5 (parser + provenance + injected-fetch refresh). 39 pass; tsc clean; build OK. Verified live: startup refresh is idempotent, a cleared game is re-pulled, and a user-edited score is preserved across a refresh.

Summary

Type of change

  • 🐛 Bug fix
  • ✨ Feature
  • 🏷️ Sticker data correction
  • 📖 Docs
  • 🧹 Refactor / chore

Checklist

  • npm test passes
  • npm run lint passes
  • For data changes: regenerated stickers.json / teams.json is committed and a source is cited below
  • I updated CHANGELOG.md if relevant

Source / notes

A new feed (services/resultsFeed.ts) pulls the latest played scores from the
public openfootball dataset (CC0) every time the server boots — in the
background, so a slow or offline network never delays startup. Elo ratings,
win/draw/win predictions, group standings and the Monte Carlo simulator are all
derived from match_results on each request, so they update live as games are
played, with no regenerate or redeploy.

- Result provenance: match_results gains a `source` column (feed vs user, via an
  idempotent migration). The feed only ever writes/overwrites its own `feed`
  rows, so any score you edit in-app (`user`) is never clobbered.
- Manual refresh: POST /api/results/refresh and a "Refresh results now" button in
  Settings pull newly-played games on demand (reports added/updated/unchanged).
- Shared parser (lib/openfootball.ts) is now used by both the build-time
  generator and the runtime feed, so the team map and score parsing can't drift
  (generator output verified byte-identical after the refactor).
- Config: LIVE_RESULTS=off disables it; RESULTS_FEED_CUP_URL / _FINALS_URL /
  _TIMEOUT_MS override the source.
- Refreshed the bundled dataset to 36 played games (only scores changed).

Tests: +5 (parser + provenance + injected-fetch refresh). 39 pass; tsc clean;
build OK. Verified live: startup refresh is idempotent, a cleared game is
re-pulled, and a user-edited score is preserved across a refresh.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ChristianAbele02 ChristianAbele02 merged commit df92768 into main Jun 21, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants