feat(me): link a signed-in user to their own driver stats - #175
Merged
Merged
Conversation
Reaching your own stats meant opening an event or the championship and finding yourself in a results table. /me now resolves the viewer to their Driver row and links straight to it. Driver.msrUid has been a unique column since the init migration with no read or write path anywhere; this is what finally uses it, so no migration is needed. Matching falls back to Driver.nameOnlyHash, computed at login from the MSR profile before the full surname is discarded, and only when exactly one Driver carries the hash -- the same rule ingest already uses for merge/adopt. computeNameOnlyHash moves to pii.ts (re-exported from ingest.ts) so the OAuth callback doesn't pull better-sqlite3 into its bundle.
The target is a Route Handler that 302s cross-origin to MSR, so the App Router client fetched an RSC payload for it, failed on the redirect, and fell back to a browser navigation -- running OAuth step 1 twice per click, minting two request tokens and writing lc_msr_req twice. landing.tsx already used a plain <a>.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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.
Reaching your own stats meant opening an event or the championship and finding yourself in a results table.
/menow resolves the signed-in viewer to theirDriverrow and links straight to it. Addresses driver feedback.Driver.msrUidhas been a unique column since theinitmigration with no read or write path anywhere in the codebase, so this needed no migration. Resolution prefers that explicit link, then falls back toDriver.nameOnlyHashand only matches when exactly oneDrivercarries the hash, the same "exactly one candidate or don't guess" rule ingest already uses for merge/adopt. The join key exists because the OAuth callback computes the digest from the MSR profile while it still has the full surname, then discards it; the hash goes in the session, the surname is still never persisted.computeNameOnlyHashmoved fromingest.tstopii.ts(re-exported, so existing importers are untouched) becauseingest.tstop-level-importsbetter-sqlite3and the OAuth callback should not pull a native SQLite driver into its bundle.Reads and writes are split deliberately:
resolveSelfDriveris pure read so rendering/mecarries no side effect, and the single write isclaimSelfDriver, called from the callback and wrapped so it can never fail a login. Cross-league aggregation needed no new code:buildDriverHistoryalready acceptsleagueIds: "all".The second commit is unrelated to the feature but was found while smoke-testing it: the
/loginsign-in button was anext/linkpointing at a Route Handler that 302s cross-origin to MSR, so the App Router client fetched an RSC payload for it, failed on the redirect, and fell back to a browser navigation, running OAuth step 1 twice per click and minting two request tokens.landing.tsxalready used a plain anchor.Verification
lint,typecheck,test(728 passing across 62 files) andbuildall clean. Newtests/driver-self.test.tscovers 12 cases across both functions, including an ambiguous hash, a row already claimed by another user, and a legacy row with a nullnameOnlyHash.Smoke-tested locally against real dev data: MSR login,
/merenders the results card, link lands on the right driver page. Note that theunmatchedandunlinkableempty states have unit coverage only and have not been viewed in a browser, and the new card has not been checked at mobile and desktop breakpoints.