fix: cap overview recent-receipts fetch to 20 rows#59
Merged
Conversation
There was a problem hiding this comment.
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 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 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) | ||
|
|
| renderHeaderContext(null, stats); | ||
|
|
||
| const receipts = await fetchJSON('/api/receipts'); | ||
| const receipts = await fetchJSON('/api/receipts?limit=20'); |
There was a problem hiding this comment.
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 thelimitquery 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 keepRECENT_LIMITfor 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 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 | ||
| } |
|
|
||
| ### 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 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 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 | ||
| } |
| } | ||
| const maxLimit = 10000 | ||
| if n > maxLimit { | ||
| writeError(w, http.StatusBadRequest, "limit must not exceed 10000") |
|
|
||
| ### 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'); | ||
|
|
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>
2944ad2 to
f6b4cff
Compare
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.
Summary
The overview tab was fetching
/api/receiptswith no limit, pulling up to 10,000 rows just to display a handful in the "Recent receipts" section. Adds?limit=20to that specific fetch inloadOverview(). The full receipts view fetch is unchanged.Test plan
go vet ./...passesgo test ./...passesCloses #58