feat(admin): paginate audit and request logs#155
Open
erwill2 wants to merge 1 commit into
Open
Conversation
Add shared, filter-preserving pagination controls and bounded page parsing for both admin log views. Clamp empty and overflow pages, preserve request-log page state during event refresh, and cover the helper plus LiveView navigation regressions.
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
Implements item 11 by adding URL-driven pagination to both admin log views using one shared pagination component and helper:
/admin/audit-logs/admin/request-logsBoth pages now render matching top and bottom controls, preserve active filters while navigating, omit
page=1from canonical URLs, show exact visible ranges, and clamp stale or overflowing page numbers.This PR is based directly on current
main(b628d7ea). The GitHub audit found no existing audit/request-log pagination PR or issue; the Jobs explorer is the closest existing UI precedent.Context
The underlying readers already expose a stable offset-pagination contract:
itemstotallimitoffsetAudit events are ordered newest-first by their existing stable ordering, and request logs are ordered by
admitted_at DESC, id DESC. The two LiveViews nevertheless always requestedlimit: 50with the default offset, so records after the first 50 were inaccessible from the admin UI.No accounting or audit query semantics needed to change. This PR wires the existing offset support into URL state and presentation.
Shared pagination design
CodexPoolerWeb.Admin.LogPaginationowns the behavior shared by both pages:pagequery parameter;1..10,000before an SQLOFFSETcan be constructed;pagewhen navigating back to page 1;The audit and request-log components only supply route-specific IDs, labels, range roles, and border placement. This avoids maintaining two copies of the same pagination markup and arithmetic.
URL and state behavior
pageor blankpageN(N - 1) * 50pagequery parameterNN; clamp only if the result count shrank below itRequest-log drawer state remains in
current_params, so opening or closing a selected request continues to preserve the current page and filters.Presentation
Both pages render pagination above and below their desktop/mobile log tables:
Page N of MShowing X-Y of ZControls render whenever the filtered result has records, including a last page that becomes temporarily empty before LiveView applies its canonical clamp.
Realtime request-log refresh
Request logs can refresh from PostgreSQL-backed events. The LiveView now stores the current page separately from parsed filters and uses that page for lightweight event refreshes. If a new row arrives, the operator remains on the current page. If rows disappear and the page is no longer valid, the view patches to the new last page.
This keeps realtime behavior consistent with explicit pagination instead of unexpectedly returning operators to page 1.
Safety and access control
Pools.list_log_filter_pools/1, audit readers, and request-log readers.Tests
The regression coverage verifies:
page=1;Showing X-Y of Zranges;Local verification:
mix compile --warnings-as-errors- passed in a clean build volumemix credo --strictfor all eight changed files - no issuesmix format --check-formattedfor the new shared module and changed test files - passedgit diff --check- passedFiles changed
Scope boundaries
This PR intentionally does not include:
Risk and rollback
The pages use the repositories' existing offset pagination, so new records can shift later pages while an operator is browsing. That is the established reader contract and is preferable here to broadening this UI change into a cursor-pagination data-layer rewrite. Stable secondary ordering prevents nondeterministic ties within a snapshot.
Rollback is a single commit revert. There are no schema changes, backfills, or irreversible writes.