fix(smugmug): match event names whose only token is a number - #179
Merged
Merged
Conversation
matchEventFolder stripped every pure-digit token from a folder's UrlName via a `!/^\d+$/` filter. That filter existed only to drop the conventional "YYYY-MM-DD-" prefix, but it is indiscriminate: it also erases digits that are part of the event name itself. An event named "The 912" tokenizes to exactly ["912"] — "the" is a STOPWORD — so the one token that identifies it was removed from the folder side too. Its gallery, 2026-09-12-The-912-Autocross, reduced to an empty contentTokens array, hit the `continue`, and the function returned null. The photos link silently never rendered. Strip only the leading date prefix, then tokenize the remainder, and reuse that same match for the date-proximity term instead of re-running a second regex. For date-prefixed folders the resulting token set is identical to before; digits inside the name now survive. This cannot loosen matching. Extra content tokens only ever lower `reverse` (matchCount / contentTokens.length) and never affect `forward`, so keeping in-name digits can only make a match stricter — except where the digit is the token we actually want. Not a regression: this code last changed in #99, well before the event. "The 912" is simply the first event name to trip it. Adds regression coverage for the match, the article-omitted folder variant, and three false-positive guards: an unrelated same-day folder, a same-named folder far from the event date, and nearest-of-two when both share the numeric token.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The fix is covered by regression tests and no unresolved issues remain.
Review effort: Lite
Findings: None
What changed in this PR
Fixes SmugMug matching for events whose meaningful name token is numeric, such as “The 912.”
Changes:
- Strip only the leading date prefix before tokenization.
- Reuse the parsed date for proximity scoring.
- Add regression tests for numeric names and date-selection boundaries.
| File | Description |
|---|---|
apps/web/tests/smugmug.test.ts |
Adds regression coverage for numeric event matching and date boundaries. |
apps/web/src/lib/smugmug.ts |
Corrects folder tokenization and date parsing. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Problem
The September event produced no Photos ↗ link, while every other 2026 event linked correctly.
This is not a regression —
src/lib/smugmug.tslast changed in #99 (2026-07-28), well before the event. It is a latent bug that "The 912" is the first event name to trip.matchEventFolderbuilt the folder's content tokens as:That filter exists only to drop the conventional
YYYY-MM-DD-prefix, but it is indiscriminate — it strips every pure-digit token, including digits that are part of the event name. The event-name side is not filtered at all.For "The 912" (2026-09-12, league
pca-rmr):tokenize("The 912")→["912"]—theis a STOPWORD, leaving one digit tokentokenize("2026-09-12-The-912-Autocross")→["2026","09","12","912"]→ digit filter →[]contentTokens.length === 0hit thecontinue, the folder was skipped, and the function returnednull. The link silently never rendered.Confirmed against the live SmugMug API: the gallery
2026-09-12-The-912-Autocrossexists, so matching was the only thing missing.Ruled out: the league-config path. "The 912" is a
pca-rmrevent whose League row hassmugmugUser=rmrpca/smugmugDisciplinePath=Autocross, soresolveSmugmugTargetreturns a valid target. The multi-league split is not involved; no SCCA event is affected.Fix
Strip only the leading date prefix, then tokenize the remainder — and reuse that same match for the date-proximity term instead of running a second regex over the same string.
This cannot loosen matching. Extra content tokens only ever lower
reverse(matchCount / contentTokens.length) and never affectforward, so retaining in-name digits can only make a match stricter — except where the digit is the token we actually want. For date-prefixed folders the resulting token set is byte-identical to before.matchCount,forward/reverse,tScore,dateScore, the0.6/0.4weighting and the strict> 0.6threshold are all untouched.Tests
Five new cases alongside the existing ones:
2026-09-12-912-Autocross)0.6 * 1.0 + 0.4 * 0is not> 0.6)Verification
lint— cleantypecheck— cleantest— 736 passed / 62 filesnext build— compiled successfullymatchEventFolderruns outside theunstable_cachelayer, so no cache bust is needed — the 1h folder-list and 1w year-node caches are unaffected and the fix takes effect on next render.Notes for deploy
No schema, migration, admin UI, or Turso work. Code-only.
Separately surfaced while testing locally (not addressed here):
dev.dbhad never had20260730010000_scoring_policy_v4applied, so every event page threwscoringPolicy.v must be 4 — got 3before reaching any photo-link code. Worth confirming that migration is applied wherever this deploys.