[dev] [Marfuen] mariano/admin-audit-pagination#3480
Conversation
The platform-admin "Recent Activity" panel hard-capped at 100 records with
no way to see older history. Add offset pagination end-to-end:
- API: `getAuditLogs` accepts `offset`, returns `{ data, total }` (parallel
count), raises the `take` ceiling to 200, and adds a stable `id` secondary
sort so offset paging is deterministic across batches.
- App: `useAdminAuditLogs` accumulates 100-row batches by offset and derives
`hasMore` from the server total.
- `RecentAuditLogs` gains optional server-pagination props: the › arrow stays
enabled until the genuine last page (ceil(total / pageSize)) and the next
batch is fetched automatically when paging past the loaded window — so the
arrow is only enabled when there's actually more to load.
Adds RecentAuditLogs pager tests (smart next-arrow from server total,
load-more at the batch boundary, legacy backward-compat) and extends the
admin-organizations service spec for offset/take/total.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…y visible
The vendor detail "Recent Activity" panel fetched /v1/audit-logs with no
offset and no total, so it only ever showed the newest 50 combined vendor +
task-item events. On a busy vendor, older `vendor` events (e.g. an assignee
change) fell off with no way to page to them — they were logged, just
unreachable in the UI.
- API: `/v1/audit-logs` now accepts `offset`, returns `{ data, total }`
(parallel count), and adds a stable `id` secondary sort so offset paging is
deterministic. `take` semantics unchanged (default 50, max 100). Purely
additive — the existing non-paginated `useAuditLogs` consumers are unaffected.
- App: extract the offset-accumulate machinery into a shared
`useOffsetAuditLogs` core (used by the admin pager too, now a thin wrapper)
and add `usePaginatedAuditLogs` for entity-scoped views. The core resets its
window when the filter identity changes (e.g. a vendor's task-item ids load).
- Vendor activity section wires the paginated hook into RecentAuditLogs' server
pager (load-more + smart next arrow).
Tests: audit-log controller spec covers offset/total/count; useOffsetAuditLogs
spec covers accumulate/dedupe/hasMore/filter-reset.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Review completed against the latest diff
Confidence score: 5/5
- Safe to merge after the addressed issues were fixed.
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 7 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
- P1: offset pager no longer skips a batch on a failed load-more. `loadMore` only advances once the current batch has settled successfully; while it's loading or errored (SWR retries the same offset) it's a no-op, so no rows are dropped from the pager. Covered by a new hook test. - Cap `offset` on both audit-log endpoints (shared /v1/audit-logs and the admin org endpoint) at MAX_AUDIT_LOG_OFFSET (100k) so an unbounded ?offset= can't force arbitrarily large table scans. Constant lives in a dependency-free module so it doesn't drag Prisma enums into unit-test module graphs. - Add the missing admin-controller test for the offset param and cap tests for both endpoints. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Picks up the new `offset` query param on GET /v1/audit-logs so the generated MCP `get-audit-logs` client can page past the first batch. Addresses the last open cubic finding on #3480. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
There was a problem hiding this comment.
All reported issues were addressed across 12 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Fix all with cubic | Re-trigger cubic
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
Follow-up to the offset cap: the endpoints returned the true row count while clamping any offset past MAX_AUDIT_LOG_OFFSET to the same page. Past the cap the client's `hasMore = logs.length < total` stayed true, so the pager looped load-more over pages that could never be filled. Report `min(count, MAX_AUDIT_LOG_OFFSET)` from both audit-log endpoints so `hasMore` and the pager's page count stop at the accessible boundary. No client change needed. Covered by cap-total tests on both specs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
🎉 This PR is included in version 3.107.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This is an automated pull request to merge mariano/admin-audit-pagination into dev.
It was created by the [Auto Pull Request] action.
Summary by cubic
Adds offset pagination to admin org and vendor activity so you can browse beyond the first window with stable ordering, a smarter pager, and safe bounds on deep paging.
New Features
getAuditLogsand/v1/audit-logsacceptoffsetand return{ data, total }with a stable sort (timestampthenid). Admin default/maxtakeis 100/200; shared endpoint is 50/100;countuses identical filters.useOffsetAuditLogscore;useAdminAuditLogs/usePaginatedAuditLogsload 100-row batches.RecentAuditLogssupports server pagination (total,hasMore,onLoadMore,isLoadingMore), keeps the next arrow enabled from the server total, auto-loads at batch boundaries, and shows a loading spinner. UpdatedOrganizationDetailand vendor activity to use the paginated hooks.openapi.jsonto add theoffsetquery param onGET /v1/audit-logs.Bug Fixes
loadMoreadvances only after the current fetch settles successfully.offsetatMAX_AUDIT_LOG_OFFSET(100k) and cap the reportedtotalto the reachable window so the pager stops correctly and avoids unbounded scans.Written for commit c6fd74a. Summary will update on new commits.