fix: derive race card location from race name when manifest lacks it#232
fix: derive race card location from race name when manifest lacks it#232rootulp wants to merge 1 commit into
Conversation
Only 690 of 1447 races in data/races.json have a location, so most cards on /races rendered without a location line and the grid looked inconsistent. Add a conservative display-time fallback that derives a location from the race name by stripping the leading year and the IRONMAN / IRONMAN 70.3 prefix (e.g. "2026 IRONMAN 70.3 Subic Bay Philippines" -> "Subic Bay Philippines"). The real manifest location always takes precedence; names that don't match the pattern (5150, Timberman, championship designations, etc.) fall back to no location rather than garbage. Applied on the /races cards and the /race/[slug] header. Closes #219 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR adds location derivation for races missing manifest data. A new utility module extracts place names from IRONMAN-format race names via regex, with manifest locations taking precedence. The race page header and race list cards now use this fallback to ensure consistent location display across all races. ChangesLocation Fallback for Race Cards
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Greptile SummaryAdds a display-time fallback so race cards show a location for IRONMAN races whose manifest entry lacks one, covering 741 of 757 previously blank cards. A new pure helper module (
Confidence Score: 5/5Safe to merge — changes are additive and display-only, with no effect on data persistence or routing. All four changed files are narrow and well-tested. The regex has dedicated tests for every null-return branch, including the "70.3" back-track edge case. The UI integration correctly guards the flag lookup and the separator character. No existing behavior is removed; the manifest location always takes precedence. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[race object] --> B{race.location trimmed non-empty?}
B -- yes --> C[return manifest location]
B -- no --> D[deriveLocationFromRaceName]
D --> E{matches year + IRONMAN pattern?}
E -- no --> F[return null]
E -- yes --> G[extract remainder]
G --> H{remainder empty or equals 70.3?}
H -- yes --> F
H -- no --> I{contains 'championship'?}
I -- yes --> F
I -- no --> J[return remainder as location]
C --> K[render in UI with flag lookup]
J --> K
F --> L[render nothing / no flag]
Reviews (1): Last reviewed commit: "fix: derive race card location from race..." | Re-trigger Greptile |
Closes #219
Summary
Only 690 of 1447 races in
data/races.jsonhave alocation, so most cards on/racesrendered without a location line and the grid looked inconsistent. This adds a display-time fallback instead of mass-scraping or hand-editing the manifest:app/src/lib/raceLocation.ts:deriveLocationFromRaceName(name)strips the leading year and theIRONMAN/IRONMAN 70.3prefix ("2026 IRONMAN 70.3 Subic Bay Philippines"→"Subic Bay Philippines","2013 IRONMAN Austria"→"Austria").nullfor names that don't match the pattern (5150 Mont-Tremblant,Victoria Olympic,Timberman Triathlon,June IRONMAN 70.3 Eagleman) and for championship designations that aren't locations (World Championship - Men), so the card renders without a location rather than garbage.getRaceLocation(race)applies precedence: the real manifestlocationalways wins; the derived value is only a fallback./races(app/src/app/races/race-list.tsx, including the country-flag lookup) and the/race/[slug]header (which also no longer renders a dangling·when there's no location).With this fallback, 741 of the 757 location-less races now display a derived location; the remaining 16 (non-IRONMAN names and championship designations) intentionally render without one.
Scraper backfill was skipped: manifest locations come from
scripts/race-registry.jsonentries, and capturing them for future scrapes would require fetching per-event metadata — not a trivial change.Test notes
app/src/lib/__tests__/race-location.test.ts(13 tests) written first and watched fail, then the helper implemented. Covers prefix variants, year placement, non-matching names, empty remainders, championship names, and the manifest-precedence rule.cd app && npx vitest run: 10 files, 98 tests passed.cd app && npm run lint: clean.npx tsc --noEmit: no errors in changed files (pre-existing errors inathlete-shards.test.tsonly).🤖 Generated with Claude Code
Summary by CodeRabbit