HarperFast / HarperFast/studio

Test database overview lazy record-count backfill

Open
#1,491 0 comments 0 reactions 0 assignees View on GitHub
good first issue
Dominant language
TypeScript
Stars
5
Forks
4
Avg merge
1d 8h
Merged PRs (30d)
40

Description

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`](../blob/stage/src/features/instance/databases/functions/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`.

Contributor guide

Open the contributing guide

Research direction

Read src/features/instance/databases/components/DatabaseOverview.tsx, then inspect the tests for resolveDatabasesRedirect.ts and buildItems.ts for the project’s pure-helper style. Extract the described settled-state, totals, estimated labels, and per-table labels into the suggested helper, refactor the overview to use it, and run npx vitest run src/features/instance/databases, npx tsc -b, and npx oxlint.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
databases, frontend, testing
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.