Skip to content

fix: cap overview recent-receipts fetch to 20 rows#59

Merged
ojongerius merged 4 commits into
mainfrom
worktree-agent-a77b248daf9fef23a
May 20, 2026
Merged

fix: cap overview recent-receipts fetch to 20 rows#59
ojongerius merged 4 commits into
mainfrom
worktree-agent-a77b248daf9fef23a

Conversation

@ojongerius
Copy link
Copy Markdown
Contributor

Summary

The overview tab was fetching /api/receipts with no limit, pulling up to 10,000 rows just to display a handful in the "Recent receipts" section. Adds ?limit=20 to that specific fetch in loadOverview(). The full receipts view fetch is unchanged.

Test plan

  • go vet ./... passes
  • go test ./... passes
  • Load dashboard with a large DB and confirm the overview loads quickly

Closes #58

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to reduce the payload and client-side work on the Overview tab by capping the /api/receipts fetch used to populate “Recent receipts”, while leaving the full receipts view unchanged.

Changes:

  • Update the Overview “Recent receipts” fetch to request /api/receipts?limit=20.
  • Add a changelog entry describing the overview fetch cap.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
internal/server/static/index.html Adds a limit=20 query param to the Overview receipts fetch.
CHANGELOG.md Documents the intended overview fetch cap under “Fixed”.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/server/static/index.html Outdated
Comment on lines 797 to 799
const receipts = await fetchJSON('/api/receipts?limit=20');
if (gen !== poller.generation) return;
renderReceiptsTable(receipts.slice(0, RECENT_LIMIT), 'recent-receipts');
Comment thread CHANGELOG.md
Comment on lines +10 to +13
### Fixed

- Overview "Recent receipts" now fetches only 20 rows from the server instead of the full store (up to 10,000 after #55), reducing unnecessary bandwidth and memory usage (#58)

Comment thread internal/server/static/index.html Outdated
renderHeaderContext(null, stats);

const receipts = await fetchJSON('/api/receipts');
const receipts = await fetchJSON('/api/receipts?limit=20');
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

internal/server/static/index.html:802

  • This uses RECENT_LIMIT (currently 10) as the limit query param, so the overview request will fetch 10 rows, not 20 as stated in the PR title/description. If the intent is to fetch 20 while still displaying 10, consider introducing a separate fetch-limit constant (e.g., RECENT_FETCH_LIMIT = 20) and keep RECENT_LIMIT for the rendered slice; also update the nearby comment about seeding polling from the “full fetch”, since this request is no longer unbounded.
        const receipts = await fetchJSON(`/api/receipts?limit=${RECENT_LIMIT}`);
        if (gen !== poller.generation) return;
        renderReceiptsTable(receipts.slice(0, RECENT_LIMIT), 'recent-receipts');

        // Seed polling from the full fetch, not the displayed slice.
        startPolling('overview', 'recent-receipts', receipts, () => ({}));

Comment thread internal/server/server.go
Comment on lines +130 to +137
if v := q.Get("limit"); v != "" {
n, err := strconv.Atoi(v)
if err != nil || n < 1 {
writeError(w, http.StatusBadRequest, "limit must be a positive integer")
return
}
f.Limit = &n
}
Comment thread CHANGELOG.md Outdated

### Fixed

- Overview "Recent receipts" now fetches only 20 rows from the server instead of the full store (up to 10,000 after #55), reducing unnecessary bandwidth and memory usage (#58)
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

Comment on lines +797 to 799
const receipts = await fetchJSON(`/api/receipts?limit=${RECENT_LIMIT}`);
if (gen !== poller.generation) return;
renderReceiptsTable(receipts.slice(0, RECENT_LIMIT), 'recent-receipts');
Comment thread internal/server/server.go
Comment on lines +130 to +142
if v := q.Get("limit"); v != "" {
n, err := strconv.Atoi(v)
if err != nil || n < 1 {
writeError(w, http.StatusBadRequest, "limit must be a positive integer")
return
}
const maxLimit = 10000
if n > maxLimit {
writeError(w, http.StatusBadRequest, "limit must not exceed 10000")
return
}
f.Limit = &n
}
Comment thread internal/server/server.go Outdated
}
const maxLimit = 10000
if n > maxLimit {
writeError(w, http.StatusBadRequest, "limit must not exceed 10000")
Comment thread CHANGELOG.md

### Fixed

- Overview "Recent receipts" now fetches only `RECENT_LIMIT` (10) rows from the server instead of the full store (up to 10,000 after #55), reducing unnecessary bandwidth and memory usage. The `/api/receipts` endpoint now honours a `?limit=N` query parameter (capped at 10,000) (#58)
Comment on lines +797 to 800
const receipts = await fetchJSON(`/api/receipts?limit=${RECENT_LIMIT}`);
if (gen !== poller.generation) return;
renderReceiptsTable(receipts.slice(0, RECENT_LIMIT), 'recent-receipts');

ojongerius and others added 4 commits May 20, 2026 17:14
The overview loadOverview() call was fetching /api/receipts with no
limit, pulling up to 10k rows to display only a handful. Add ?limit=20
to that specific fetch; the full receipts view is unchanged.

Closes #58

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@ojongerius ojongerius force-pushed the worktree-agent-a77b248daf9fef23a branch from 2944ad2 to f6b4cff Compare May 20, 2026 05:16
@ojongerius ojongerius merged commit d81c92f into main May 20, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Overview fetches unbounded receipts for "Recent" display

2 participants