feat(seed): conditionally seed demo locations when their R2 objects exist - #41
Merged
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
7 tasks
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.
Closes the
prisma/seed.tshalf of #10. The frontend half landed in #36.Why it is conditional rather than a plain upsert
I argued against seeding at all in #36, and that reasoning still holds: a seed can write
Locationrows but cannot create their R2 objects. A row markedreadywhosergbImageUrl/maskPath/monthlyFluxPathpoint at objects a bucket does not contain fails later and more confusingly than a clean cache miss — the app thinks it has a cached location and then cannot render it.So
seedDemoLocations()writes a row only when it can prove the assets exist. Per location, in order:buildingInsightsJsonin this database → skip. "the seed never fabricates Solar API payloads." In a fresh environment all four take this path.HeadObjectprobe 404s on any path → skip, listing the missing objects, so the cache misses cleanly.Missing R2 env skips the whole phase with one log line, and the demo phase is wrapped so it can never take the required
TariffConfigseed down with it.Idempotency is find-then-create keyed on the same
0.0001toleranceresolveLocationuses —Locationhas no unique constraint on lat/lng, soupsertwould not work.Known wart
The demo coordinates are duplicated from
frontend/src/lib/demoLocations.ts. A clean import was not possible: the seed runs as plain Node with type stripping and no path aliases, and reaching intofrontend/srcwould drag React types across the workspace boundary. The constant carries a comment naming the other file and the drift risk.Worth hoisting into
shared/later — noting thatsharedbuilds to JS, so the seed would need a runtime path into that build. Drift here is not cosmetic: these coordinates only work because they match cached rows within 11 m, so a stale copy silently converts a cache hit into a Solar API call.Verified
tsc --noEmit -p backend/tsconfig.jsonexit 0 ·node --checkon both files exit 0 · import smoke test exportsseedDemoLocations· Prettier clean on both files.Not executed against any database — the
HeadObjectpath is untested against real credentials. Also noteprisma/is in no tsconfig, so the backend typecheck does not actually cover these files; a direct strict check was run instead.Implemented by the qwen3.8-max peer session; verified here.
https://claude.ai/code/session_01URDpaxhXyPLWnUQtvowNyM