perf(data-pages): replace O(N) linear-scan with direct /v1/<kind>/:slug lookup#14
Open
chrisjmendez wants to merge 1 commit into
Open
perf(data-pages): replace O(N) linear-scan with direct /v1/<kind>/:slug lookup#14chrisjmendez wants to merge 1 commit into
chrisjmendez wants to merge 1 commit into
Conversation
…ug lookup Two data profile pages were fetching 500 records and then .find()-ing the slug we actually needed. The REST API already exposes GET /v1/<kind>/:slug (mounted by buildDomainRouter), which does the lookup in O(1). Switching cuts per-page bytes-over-the-wire by ~100x and removes a latent CF-throttle risk during ISR revalidation. Files changed: - apps/web/src/app/data/compatibility/[slug]/page.tsx - apps/web/src/app/data/deploys/[slug]/page.tsx Both now mirror the pattern already used by benchmarks/[slug]/page.tsx. Scope note: the papers/[slug] page (also cited in #9) needs separate API work first: /v1/papers/paper16 returns 404 today because the seeded slug column does not match the in-JSON id. That gets its own PR after a schema/seed alignment. Refs: #9 Signed-off-by: chrisjmendez <65565+chrisjmendez@users.noreply.github.com>
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 #9 (partially — see scope note).
What changed
Two data profile pages were fetching 500 records and then
.find()-ing the slug we actually needed. The REST API already exposesGET /v1/<kind>/:slug(mounted bybuildDomainRouter), which does the lookup in O(1). Switching cuts per-page bytes-over-the-wire by ~100× and removes a latent CF-throttle risk during ISR revalidation.apps/web/src/app/data/compatibility/[slug]/page.tsxfetch(/v1/compatibility-edges?limit=500)+.find()fetch(/v1/compatibility-edges/${slug})apps/web/src/app/data/deploys/[slug]/page.tsxnew FestivusClient().searchDeployNotes({ limit: 500 })+.find()fetch(/v1/deploy-notes/${slug})Both now mirror the pattern already used by
apps/web/src/app/data/benchmarks/[slug]/page.tsx.Scope note: papers excluded
Issue #9 lists three pages. This PR refactors two. The third —
apps/web/src/app/data/papers/[slug]/page.tsx— needs separate API work first:GET /v1/papers/paper16returns404 not_foundtoday even though the Prismapaperstable has aslugcolumn. The seeded slug values do not match the in-JSONidfield that the URL passes through. Fixing that is a schema/seed alignment, not a page refactor; it gets its own PR.Verify
pnpm check(typecheck + lint): ✅ greenpnpm test: 605/606 — the one failure is the local-api canary that needs a runninglocalhost:8000. Re-run against the production API:FESTIVUS_DATASET_API_URL=https://api.festivus.hapticlabs.ai npx vitest run tests/seed-validation/festivus-api-canary.test.ts→ 1/1 passescurl -o /dev/null -w "%{http_code}" https://api.festivus.hapticlabs.ai/v1/compatibility-edges/franka-research-3__openvla-openvla-7b→200curl -o /dev/null -w "%{http_code}" https://api.festivus.hapticlabs.ai/v1/deploy-notes/deploy-arm-1→200DCO
Signed-off-bytrailer on the commit.Test plan after merge
/data/compatibility/franka-research-3__openvla-openvla-7b) → still renders.limit=500list.Refs: #9