Repository navigation
Serve Dive Log history actions from the shared data cache - #337
Conversation
Co-Authored-By: Chad <chadnuttall1@gmail.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Sorry @devin-ai-integration[bot], this account has used its review budget of 1,500,000 diff characters for the last 7 days. You can request another review in 2 hours by commenting |
|
Important Review skippedBot user detected. Ask an organization administrator to verify that this bot has an active assigned CodeRabbit review seat. See the seat-assignment guide. After the seat is confirmed, request a review again.
|
Co-Authored-By: Chad <chadnuttall1@gmail.com>
Reviewer's GuideAPIKeep public Dive Log history loads on the shared hourly data cache and remove the uncached
Uses of the APIRoute anonymous range and site history actions through a bounded per-instance loader so identical requests share successful results and failures remain retryable.
ImplementationAdd a server-only shared loader that coalesces in-flight work, retains successes for a TTL, evicts failures, and caps retained keys.
DocumentationDocument the new cache behavior, bounded staleness, and client-side merge rationale for Dive Log history actions.
TestsUpdate action tests for cached loads and cover reuse, key separation, and retry behavior after failures.
Verify the dives client uses the shared data cache and rotates its cache-key header hourly.
Test shared-loader coalescing, TTL reuse, failure eviction, and entry limits.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary
Remediates code-scan finding
sfind-f9e219312b4343069479b36e0ca794bb: the anonymous server actionsloadDiveLogHistory/loadDiveLogSiteHistorypassedfresh: truetoloadPublicDivesFromApi, whichgetJsonturned intocache: "no-store", so every anonymous call re-walked up toMAX_PAGES(200) uncached upstream pages.freshoption is removed entirely, so no caller can request uncached pages any more; every upstream page goes through the shared Next data cache (hourly, same as the page).X-Cache-Window(hourly bucket) is part of Next's fetch cache key. Without it, Next serves an expired entry once while refreshing in the background, so after a long idle the first wider load could be arbitrarily old (e.g. missing dives older than the page's 14-day window). Staleness is now bounded to one hour.createSharedLoader(lib/public-diving/shared-load.ts, server-only) coalesces concurrent identical loads per instance and reuses a successful result for 5 min (max 64 keys; keys arerange:<startDate|all>/site:<resolved siteId>, so the input space is already bounded by the existing range allowlist and site lookup). Rejections are evicted, so "Try again" reaches the API.docs/PUBLIC_DIVING_API.md.Verification
npm run lint,npm run typecheck,npm test(789 tests),npm run check,npm run build:test: all pass.desktop-chromium: 154 passed, 7 skipped.next startbuild against a local 250-dive mock API): firstloadDiveLogHistory("all")hit 3 upstream pages; 5 concurrent + 5 sequential repeats hit 0; 3 site loads hit the sites list + 2 pages once; invalid range rejected with no upstream call; after a server restart (empty in-memory loader) a repeat hit 0 upstream pages (served from the data cache). Browser: selecting "All" range still widens the list.No Vercel/Firewall or env changes are required.
Link to Devin session: https://app.devin.ai/sessions/ab448ba992124a9da8ad821c37071248
Open in Devin Desktop: https://app.devin.ai/desktop/session/ab448ba992124a9da8ad821c37071248?variant=devin
Requested by: @spizeck
🟢 Devin Review found nothing to fix · View findings · Follow Devin's work
Summary by Sourcery
Keep anonymous Dive Log history requests on the shared data cache to prevent repeated uncached upstream page walks.
Bug Fixes:
Enhancements:
Documentation:
Tests: