Skip to content

perf: paginate the subscribers admin list (closes #16)#42

Merged
payown merged 1 commit into
mainfrom
fix/issue-16-subscribers-pagination
Jun 16, 2026
Merged

perf: paginate the subscribers admin list (closes #16)#42
payown merged 1 commit into
mainfrom
fix/issue-16-subscribers-pagination

Conversation

@payown

@payown payown commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Phase 4. Closes #16.

What

The Subscribers screen loaded every row in one unbounded query. Now it paginates at 50/page with LIMIT/OFFSET and a core paginate_links() nav.

  • Count line uses the true COUNT(*) total (and _n() for singular/plural).
  • Empty state keys off the total; $paged is clamped so out-of-range pages never render empty.
  • The hashtag filter is preserved across pages (and submitting the filter resets to page 1, since the filter form carries no paged).

Accessibility

accessibility-lead reviewed. Key fix from that review: paginate_links() is echoed directly rather than through wp_kses_post(), which would strip the aria-current="page" indicator (WCAG 4.1.2). Nav has a unique aria-label="Subscribers pagination".

Verify

With >50 subscribers: pages of 50, working Previous/Next, current page marked, filter preserved across pages, accurate total count.

Closes #16

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings June 16, 2026 15:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Outpost admin “Subscribers” screen to avoid loading all subscriber rows at once by adding server-side pagination and a WordPress core pagination UI, addressing performance concerns raised in issue #16.

Changes:

  • Add bounded subscriber queries using LIMIT/OFFSET with a fixed page size (50).
  • Compute a true total row count (COUNT(*)) and use _n() for the count line.
  • Add paginate_links() navigation while preserving the hashtag filter across pages.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +26 to +35
// Total count (respects the optional hashtag filter), used for the count
// line and to bound pagination.
if ( $hashtag_id ) {
$rows = $wpdb->get_results( $wpdb->prepare(
"SELECT s.*, h.hashtag FROM {$wpdb->prefix}outpost_subscribers s
JOIN {$wpdb->prefix}outpost_hashtags h ON h.id = s.hashtag_id
WHERE s.hashtag_id = %d ORDER BY s.created_at DESC",
$total = (int) $wpdb->get_var( $wpdb->prepare(
"SELECT COUNT(*) FROM {$sub_table} WHERE hashtag_id = %d",
$hashtag_id
) );
} else {
$rows = $wpdb->get_results(
"SELECT s.*, h.hashtag FROM {$wpdb->prefix}outpost_subscribers s
JOIN {$wpdb->prefix}outpost_hashtags h ON h.id = s.hashtag_id
ORDER BY s.created_at DESC"
);
$total = (int) $wpdb->get_var( "SELECT COUNT(*) FROM {$sub_table}" );
}
Comment thread admin/views/subscribers.php Outdated
}

$total_pages = (int) max( 1, ceil( $total / $per_page ) );
$paged = max( 1, isset( $_GET['paged'] ) ? (int) $_GET['paged'] : 1 );
@payown payown force-pushed the fix/issue-16-subscribers-pagination branch from b14016e to b28009e Compare June 16, 2026 17:10
Replace the unbounded query with LIMIT/OFFSET pagination (50/page) plus an
accessible paginate_links() nav. The count line reflects the true total via
COUNT(*), the empty state keys off that total, and the page index is clamped
so an out-of-range page never renders empty. The hashtag filter is preserved
across pages. paginate_links() is echoed directly (not through wp_kses_post,
which strips aria-current) per accessibility-lead review. Local vars are
prefixed to avoid clobbering the $paged/$per_page WordPress globals.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@payown payown force-pushed the fix/issue-16-subscribers-pagination branch from b28009e to f605df7 Compare June 16, 2026 17:12
@payown payown merged commit 4199b07 into main Jun 16, 2026
1 check passed
@payown payown deleted the fix/issue-16-subscribers-pagination branch June 16, 2026 17:12
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.

perf: paginate the subscribers admin list (currently an unbounded query)

2 participants