Skip to content

fix(web): wire up server-side pagination on Content Optimization list - #633

Merged
gkhngyk merged 1 commit into
ansvisor:mainfrom
d180:feature/content-opportunities-pagination
Aug 4, 2026
Merged

gkhngyk merged 1 commit into
ansvisor:mainfrom
d180:feature/content-opportunities-pagination

Conversation

@d180

@d180 d180 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

The Content Optimization list always fetched with a fixed limit: 100 and no offset, while the UI advertised the full server-side total via the "{total} Available" badge and Total KPI. Any brand with more than 100 opportunities could never reach the rest from the UI — the numbers shown didn't match what was actually reachable.

  • getOpportunities is now called with limit: PAGE_SIZE, offset: pager.start instead of a fixed limit: 100.
  • Wires up the shared usePagination/TablePager (web/src/components/table-pager.tsx), already used on the Citations page, driven by the real server total rather than a local array length (Content can't pre-fetch everything client-side the way Citations does).
  • The pager resets to page 0 whenever the status/impact/type filters change (resetKey pattern, matching Citations).
  • The highImpact/avgScore/sentCount KPIs now reflect only the current page instead of silently summarizing whatever was in the first 100-row fetch — matching what the table can actually show. The total/"Available" badge continues to reflect the true server-side count.
  • Bulk-select (selectedIds) was already scoped to filtered, derived from opportunities — now that opportunities holds real per-page data, selection is naturally page-scoped with no extra changes needed.

Note: the search box remains a client-side-only filter over the current page (the /api/content/brand/:id route has no search param) — that's a pre-existing gap, unchanged by this PR and out of scope for the issue's acceptance criteria.

Related issue

Closes #610

Type of change

  • fix — Bug fix

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Clean wiring — total-driven pager, filter-key reset, and page-scoped selection all check out. One non-blocking note: the search box now filters only the visible page (it used to scan the loaded 100); server-side search would be a natural follow-up. Thanks!

@gkhngyk
gkhngyk merged commit 8861eb6 into ansvisor:main Aug 4, 2026
4 checks passed
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.

Content Optimization: list silently caps at 100 opportunities while advertising the full total — wire up the shared TablePager

2 participants