please use an agent team and investigate this issue: # Leaderboard Missing Athletes Investigation Report
Date: 2026-02-16
Reporter: Claude Code (initial investigation)
Status: Root cause partially identified, further investigation needed
Summary
The All Valley Open 2026 leaderboard at mountainwestfitnesschampionship.com/all-valley-open is missing 12 of 70 registered athletes. The CSV export from Competition Corner shows 70 registrations; the API returns only 58.
Architecture Overview
code
Competition Corner (registration source of truth)
↓ (sync mechanism — unknown)
PlanetScale MySQL DB
↓
mwfc-api (Cloudflare Worker) → GET /leaderboard/:competitionId
↓
mwfc (Next.js frontend, React Query client-side fetch)
API repo:/Users/zacjones/Documents/02.Areas/wodsmith/mwfc-api
API endpoint:https://mwfc-api.mountainwestchampionship.workers.dev
Competition ID:comp_sfy558a952ov789d6x525pa3
DB: Plaaccessed via @planetscale/database + Drizzle ORM)
Findings
1. The 12 Missing Athletes
All missing athletes registered between Feb 9-15, 2026. All registrations from Jan 22 - Feb 8 are present.
Athlete
Affiliate
Division
Registered
David Poulsen
Boise CrossFit
Men's Open
Feb 10
Jill Forkner
CrossFit Canvas
Women's Open
Feb 10
Elizabeth Krmpotich
CrossFit Canvas
Women's Open
Feb 10
Kevin Bobzien
CrossFit Northside
Men's Open
Feb 11
Katie Clune
Four Rivers CrossFit
Women's Open
Feb 11
Justin McKerrow
Assistant
I'll investigate this across the related repos in parallel. Let me set up a team to explore the sync mechanism.
Assistant
All three investigations converge on the same answer. Let me read the key files to confirm and narrow down the exact cause.
Assistant
Now let me check the leaderboard query to confirm what it reads.
Assistant
Let me check if there's any All Valley Open specific import script or seed file.
Assistant
Investigation Summary
Root Cause: No Sync Between Competition Corner and PlanetScale
The All Valley Open 2026 uses two separate, unconnected registration systems:
System
Purpose
Data Store
WODsmith (wodsmith-start)
Primary registration + payment
User
WE ONLY USE WODSMITH FOR THIS IDK WHERE THE COMPETITION CORNER STUFF WAS INTRODUCED. THERE WAS NO WAY COMPETITION CORNER WAS INVOLVED
Assistant
Got it — Competition Corner is a red herring from the original report. All 70 registered through WODsmith, so 12 competition_registrations rows were lost or never written. Let me investigate the actual cause.
Assistant
The D1→PlanetScale migration script was created on Feb 9 — exactly matching the cutoff date. The export was taken from D1 at that point, and registrations after the export were lost. Let me verify against the D1 database.
Assistant
D1 has 68 registrations, PlanetScale has 58, CSV has 70. So:
10 lost in D1→PS migration (68 → 58)
2 registered after the D1 export was taken (68 → 70)
Let me get the details.
Assistant
D1 has all 68 but PlanetScale only 58. The 2 newest (Taylor Duke, Austin Andreasen — Feb 15) aren't in D1 either, so they registered after the switch to PlanetScale.
Let me trace exactly what happened during migration.
Assistant
The migration uses INSERT IGNORE — rows with constraint violations are silently dropped. Let me compare D1 vs PlanetScale to find the exact 10 lost rows.
Assistant
Let me check PlanetScale directly to see which registration IDs exist. I'll use the mwfc-api's DATABASE_URL.
Assistant
Now let me diff the two sets to find the exact 10 missing IDs.
Assistant
Now let me check what these 10 have in common — likely a column value that caused INSERT IGNORE to fail.
Assistant
The 10 missing all registered Feb 9-11 — right around when the D1 export was taken. Let me verify the timeline — when was D1 actually replaced by PlanetScale?
Assistant
Found it. The D1→PlanetScale switch happened on Feb 3 (commit 003acc95). Here's the full picture:
Migration script ran: Imported export to PlanetScale using INSERT IGNORE
Production switched to PlanetScale: ~Feb 13 (PR #223 merged)
10 athletes registered in D1 AFTER the export (Feb 9-11) — never migrated
The 10 Lost in Migration (in D1 but not PlanetScale)
These registered in D1 after the export snapshot was taken:
Athlete
Registered
User in PS?
User
yes backfill
Assistant
Let me get all the data needed from D1 first.
Assistant
Now I have all the D1 data. Let me check what already exists in PS, then write the backfill script.
Assistant
Now let me look at the PlanetScale schema to make sure I write the INSERT statements correctly.
Assistant
Now I have all the data. Let me write the backfill script.
Assistant
Let me do a dry run first.
Assistant
Dry run looks good. All 47 statements, correct data. Ready to run it live?
Assistant
All 47 statements succeeded. PlanetScale now has 68 registrations (up from 58). Let me verify the leaderboard API.
Assistant
10/10 backfilled athletes now showing on the leaderboard. API went from 58 → 68 athletes.
To answer your question — the data came from D1 (your old database). The D1→PlanetScale migration took a snapshot export of D1 on Feb 9. These 10 athletes registered in D1 after that snapshot, so they existed in D1 but never made it to PlanetScale. I queried D1 directly via wrangler d1 execute wodsmith-db-prod --remote to pull their records.
Still missing: Taylor Duke and Austin Andreasen (Feb 15 registrations). They're not in D1 OR PlanetScale — they may have had failed registrations or need to re-register. Want me to investigate those 2 further?
User
ok here is austin and taylors data, please add them "1","Taylor Duke","<PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>","Men’s Open Division","","Snake River CrossFit","Feb 15, 2026","","Unisex X-Large","Feb 15, 2026" "2","Austin Andreasen","<PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>","Men’s Open Division","","Snake River CrossFit","Feb 15, 2026","","Unisex Large","Feb 15, 2026"
Assistant
All 70 athletes now on the leaderboard. CSV matches API: 70/70.
Note: Taylor and Austin were created with temporary passwords (none set — password_hash is empty). They'll need to use "forgot password" to set one if they want to log in to WODsmith directly.
Four Rivers CrossFit
Men's Open
Feb 10
Emma Myers
Four Rivers CrossFit
Women's Open
Feb 10
Angie Hemenway
Four Rivers CrossFit
Women's Open
Feb 10
Leon Fuller
Four Rivers CrossFit
Men's Open
Feb 9
Lance Silva
Four Rivers CrossFit
Men's Open
Feb 9
Taylor Duke
Snake River CrossFit
Men's Open
Feb 15
Austin Andreasen
Snake River CrossFit
Men's Open
Feb 15
2. Correct Gym Athlete Counts (CSV vs API)
Gym
CSV (expected)
API (actual)
Missing
Boise CrossFit
15
14
1
CrossFit Canvas
19
17
2
CrossFit Northside
7
6
1
Four Rivers CrossFit
20
14
6
Snake River CrossFit
9
7
2
Total
70
58
12
3. Issues Fixed During Investigation
Two issues were fixed and deployed to the API during this investigation:
a. INNER JOIN dropping registrations (mwfc-api/src/services/leaderboard.ts:209)
The registration query used INNER JOIN users — any competition_registrations row without a matching users row was silently dropped.
Changed to LEFT JOIN so missing user records don't exclude athletes.
This did NOT account for the 12 missing athletes — they don't have competition_registrations rows at all.
b. CDN caching (mwfc-api/src/index.ts:77)
Response header was Cache-Control: s-maxage=60, allowing Cloudflare edge to serve stale data for up60 seconds.
Changed to Cache-Control: no-store for fresh data on every request.
This was not the root cause but was cleaned up for correctness.
4. Root Cause: Registration Sync Failure
The 12 missing athletes exist in Competition Corner (the registration platform) but have no rows in the PlanetScale competition_registrations table. The cutoff appears to be around Feb 8-9, 2026 — everything before that date synced; nothing after did.
Next Steps for Investigation
Identify the sync mechanism — How do Competition Corner registrations get into PlanetScale? Possible mechanisms:
Webhook from Competition Corner → some worker/function that writes to PlanetScale
Cron job / scheduled worker that polls Competition Corner API
Manual import process
Part of the wodsmith ecosystem (check /Users/zacjones/Documents/02.Areas/wodsmith/ for related projects like agent, wodsmith-brain, daily-dotcom-scrape-workflow)
Check the sync service logs — Look for errors starting around Feb 8-9, 2026.
Verify DB state — Run this query against PlanetScale to confirm the 12 athletes are truly missing:
sql
SELECT COUNT(*) FROM competition_registrations
WHERE event_id = 'comp_sfy558a952ov789d6x525pa3';
-- Expected: 70, currently returning: 58
Check for a Competition Corner API — The useScheduleData.ts hook references Competition Corner heat data APIs, confirming integration exists. There may be a registration sync endpoint as well.
Backfill the 12 missing registrations once the sync issue is resolved.
Reference Files
CSV source of truth: docs/the-all-valley-open-2026-athletes-2026-02-16.csv
API leaderboard service: mwfc-api/src/services/leaderboard.ts
The mwfc-api leaderboard reads only from PlanetScale. There is no automated sync from Competition Corner → PlanetScale. Zero. No webhooks, no cron, no scheduled workers.
Why 12 Athletes Are Missing
The 12 missing athletes are exactly registration numbers #1–12 in the CC CSV (the most recent). Athletes #13–70 registered through WODsmith (writing to PlanetScale). The 12 missing ones registered only on Competition Corner — their waivers are signed, but they never went through the WODsmith registration flow, so no competition_registrations rows exist.
The date overlap on Feb 9 (some present, some missing) confirms it's not a date-based cutoff — it's about which platform the athlete used to register.
The Only CC Import Script
scripts/fetch-mwfc-registrations.ts exists but was built specifically for MWFC 2025 (team comp, event ID 15905). It fetches heat/station data from competitioncorner.net/api2/v1/schedule/workout/{id} and generates SQL. It does not work for the All Valley Open.
Fix Options
Backfill script — Write a script that reads the CSV (docs/the-all-valley-open-2026-athletes-2026-02-16.csv) and inserts the 12 missing athletes into PlanetScale's competition_registrations table for comp_sfy558a952ov789d6x525pa3
Have the 12 athletes register on WODsmith — Direct them to wodsmith.com/compete/the-all-valley-open-2026/register
Adapt the fetch script — Modify fetch-mwfc-registrations.ts to support the All Valley Open's CC event and do incremental upserts
Option 2 is cleanest (proper user accounts, payments, etc.). Option 1 is fastest for immediate fix. Want me to pursue one of these?
Lance Silva
Feb 9
No
Leon Fuller
Feb 9
Yes (account existed before export)
Angie Hemenway
Feb 10
No
David Poulsen
Feb 10
No
Justin McKerrow
Feb 10
No
Emma Myers
Feb 10
No
Jill Forkner
Feb 10
No
Elizabeth Krmpotich
Feb 10
No
Kevin Bobzien
Feb 11
No
Katie Clune
Feb 11
No
Only 1 of 10 has a user record in PlanetScale (Leon Fuller — he created his account before the export but registered for the comp after).
The 2 Not in Any DB (Taylor Duke, Austin Andreasen)
Registered Feb 15 per the CSV, but exist in neither D1 nor PlanetScale. Either their registration failed silently, or the CSV came from a different source than WODsmith.
Fix
Need to backfill from D1 → PlanetScale:
8 user records (all except Leon Fuller)
10 team_membership records (competition event team memberships)
10 competition_registration records
Plus investigate the 2 missing from both databases.
Want me to write a backfill script that reads from D1 and inserts into PlanetScale?