Skip to content

feat(api): Link header + true total count on timeentry/bycompany#72

Merged
CryptoJones merged 1 commit into
masterfrom
feat/timeentry-link-header-pagination
May 18, 2026
Merged

feat(api): Link header + true total count on timeentry/bycompany#72
CryptoJones merged 1 commit into
masterfrom
feat/timeentry-link-header-pagination

Conversation

@CryptoJones
Copy link
Copy Markdown
Owner

Summary

Rolls #71's Link-header pagination through /v1/timeentry/bycompany/:id. Three things in one commit:

  1. Switched to findAndCountAllcount in the response body now reflects total matching rows, not page length. Previously misleading on multi-page results.
  2. Link header with next / prev / first / last URLs, exposed via CORS.
  3. offset surfaced in body envelope — was missing from listByCompany's response despite the schema accepting it.

Test plan

  • vitest: 269 + 4 integration skipped (unchanged; existing timeentry tests still pass)
  • Live integration to verify the Link header against real data (deferred)

Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/

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>
@CryptoJones CryptoJones merged commit 3a7cc54 into master May 18, 2026
2 of 3 checks passed
@CryptoJones CryptoJones deleted the feat/timeentry-link-header-pagination branch May 18, 2026 02:20
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.

1 participant