feat(api): Link header + true total count on timeentry/bycompany#72
Merged
Merged
Conversation
Continues the Link-header rollout (#71). Two related changes bundled here: 1) Switch listByCompany from TimeEntry.findAll to findAndCountAll so the `count` field in the body reflects the **total** matching rows, not just the current page's length. Old behavior was misleading — a 2-page result with 30 total entries (page size 25) returned `count: 25` on page 1 and `count: 5` on page 2, with no way to know there were 30 in all. 2) Wire the Link header builder. Same Access-Control-Expose- Headers: Link header as customer/bycompany. 3) Also surfaces `offset` in the body envelope (it was missing from listByCompany even though the schema accepts it). No new tests added — the existing timeentry suite covers the auth contract and the body still has count/limit/timeEntries (plus the new offset). Link-header tests live in tests/unit/pagination.test.js. Suite: 269 / 269 + 4 integration skipped (unchanged). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Rolls #71's Link-header pagination through
/v1/timeentry/bycompany/:id. Three things in one commit:findAndCountAll—countin the response body now reflects total matching rows, not page length. Previously misleading on multi-page results.next/prev/first/lastURLs, exposed via CORS.offsetsurfaced in body envelope — was missing fromlistByCompany's response despite the schema accepting it.Test plan
Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/