Add live results feed that auto-updates scores at startup#17
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
sourcecolumn (feed vs user, via an idempotent migration). The feed only ever writes/overwrites its ownfeedrows, so any score you edit in-app (user) is never clobbered.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
Checklist
npm testpassesnpm run lintpassesstickers.json/teams.jsonis committed and a source is cited belowCHANGELOG.mdif relevantSource / notes