Skip to content

Test database overview lazy record-count backfill #1491

Description

@dawsontoth

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions