Repository navigation
perf(importers): paginate surety_admin importer list, inline bond/metrics via JOIN - #1261
Open
omarima-10 wants to merge 1 commit into
Open
omarima-10 wants to merge 1 commit into
omarima-10 wants to merge 1 commit into
Conversation
…st (vjuliaife#250) Replaces the unpaginated surety_admin importer list with a single JOIN query that resolves each importer's most recent bond_records row (via LEFT JOIN LATERAL) and its importer_metrics row inline, instead of requiring a separate request per importer for that data. Adds ?page=&limit= (max 100, default 50) query params backed by listSuretyAdminImporters in db.ts, and fixes the admin branch's response keys, which were being returned as raw snake_case Postgres column names while the frontend's Importer type, and every other importer field the dashboard reads, is camelCase. Verified against a fresh local Postgres instance seeded directly from the schema in db.ts (the committed migration chain currently has several pre-existing, unrelated breaks: duplicate migration version numbers at 12 and 13, and 0008 referencing api_keys before 0015 creates it, not touched here).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Deployment failed for project tariff-shield-web with the following error: Learn More: https://vercel.com/docs/concepts/projects/project-configuration |
This branch had an error being 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.
closes #250
What changed
GET /importersforsurety_adminalready ran as a single JOIN query (not the N+1 described in the issue's premise, confirmed via git blame: it was written this way from the start). What was actually missing against the acceptance criteria:?page=&limit=, max 100, default 50, vialistSuretyAdminImportersindb.ts)LEFT JOIN LATERALagainst the importer's most recentbond_recordsrow, plus aLEFT JOINagainst theimporter_metricsmaterialized view)Also fixed along the way: the admin branch was returning raw snake_case Postgres column names (
legal_name,bond_id, ...) while the frontend'sImportertype and every other field the surety dashboard reads is camelCase, so the admin importer list was silently rendering blank forlegalName/bondId/stellarAddress. Same object construction site as the pagination fix, so fixed together rather than as a separate PR.Testing
Added
apps/api/src/__tests__/integration/surety-admin-importers-list.test.ts(5 cases): correct page size/total, no overlap across pages, picks the newestbond_recordsrow per importer, includes theusersJOIN email, includes metrics fields. All 5 pass against a locally seeded Postgres instance.Disclosure: the repo's committed migration chain (
apps/api/src/migrations/) currently has pre-existing, unrelated breaks unconnected to this change: duplicate migration version numbers at 12 and 13 (three0012_*.tsfiles, two0013_*.tsfiles), and0008_dev_usage_and_onboarding_drip.tsreferencingapi_keysbefore0015_importer_api_keys.tscreates it. Reproduced against a clean clone ofmain, not introduced here. Worked around it locally for this PR's own test run by seeding directly from the schema embedded indb.ts.