Follow-up from the review of #1471 (databases tab redesign). Reviewers @kriszyp and @DavidCockerill noted the overview's lazy record-count backfill isn't covered by tests.
File
src/features/instance/databases/components/DatabaseOverview.tsx
The overview renders sizes/schema instantly from the fast describe_all map (the instanceDatabaseMap prop, fetched with skipRecordCount) and backfills per-table record counts via useQueries over getDescribeTableQueryOptions — for only the shown database's tables.
Behaviors to lock in
- The aggregate Records stat shows
… until all count queries have settled (countQueries.every(q => !q.isPending)), then sums the counts that resolved. Because getDescribeTableQueryOptions uses retry: false, a single failed / never-resolving describe_table must not hang the total on … — it still shows the sum of the resolved ones.
- The total is prefixed with
~ when any contributing count is estimated (estimated_record_range present), matching the per-row labels.
- Per-row: size (
table_size), column count (attributes.length), primary key (primary_key ?? hash_attribute ?? '—') come from the map; the record label shows … until that table's count resolves, then ~N if estimated.
Suggested approach
Extract the count-aggregation logic (settled?, total, anyEstimated, per-table label) into a small pure helper (e.g. functions/summarizeDatabaseCounts.ts) taking the table list + an array of { data?, isPending } query-like results, and unit-test the helper directly — mirrors how resolveDatabasesRedirect.ts and buildItems.ts are tested (no rendering needed). Refactor DatabaseOverview to use it.
Verify with npx vitest run src/features/instance/databases, npx tsc -b, npx oxlint.
Follow-up from the review of #1471 (databases tab redesign). Reviewers @kriszyp and @DavidCockerill noted the overview's lazy record-count backfill isn't covered by tests.
File
src/features/instance/databases/components/DatabaseOverview.tsxThe overview renders sizes/schema instantly from the fast
describe_allmap (theinstanceDatabaseMapprop, fetched withskipRecordCount) and backfills per-table record counts viauseQueriesovergetDescribeTableQueryOptions— for only the shown database's tables.Behaviors to lock in
…until all count queries have settled (countQueries.every(q => !q.isPending)), then sums the counts that resolved. BecausegetDescribeTableQueryOptionsusesretry: false, a single failed / never-resolvingdescribe_tablemust not hang the total on…— it still shows the sum of the resolved ones.~when any contributing count is estimated (estimated_record_rangepresent), matching the per-row labels.table_size), column count (attributes.length), primary key (primary_key ?? hash_attribute ?? '—') come from the map; the record label shows…until that table's count resolves, then~Nif estimated.Suggested approach
Extract the count-aggregation logic (settled?, total,
anyEstimated, per-table label) into a small pure helper (e.g.functions/summarizeDatabaseCounts.ts) taking the table list + an array of{ data?, isPending }query-like results, and unit-test the helper directly — mirrors howresolveDatabasesRedirect.tsandbuildItems.tsare tested (no rendering needed). RefactorDatabaseOverviewto use it.Verify with
npx vitest run src/features/instance/databases,npx tsc -b,npx oxlint.