ReviewOS

stacks/wildloop

Add pagination metadata to list endpoints

#978
Closed glennmichael123 opened this 9 days ago ·
9 days ago

Problem

ActivityIndexAction/TrailIndexAction return a bare array (or only total) with no offset/limit/hasMore, making real pagination/infinite-scroll impossible.

Acceptance

  • offset/limit params + meta: { offset, limit, total, hasMore } on list endpoints.
8 days ago

Done in a86e2d6 (+ review fixes in ee82b1c).

List endpoints returned a bare array (TrailIndex) or only { total }. Now every list endpoint returns meta: { offset, limit, total, hasMore } and accepts offset/limit params.

  • Shared resources/functions/pagination.ts (readPageParams + paginate); total is the real match count regardless of page.
  • Applied to ActivityIndex, TrailIndex (the named ones) + ClubIndex, ChallengeIndex, TrailReviewIndex, SavedTrailIndex, UserSearch.
  • TrailIndex was a bare array → now { success, trails, meta }, backward-compatible (the catalog's extractApiTrailRows already reads .trails).

Review fixes folded in: UserSearch had a DB-side .limit(20) running before paginate(), so total capped at 20 and hasMore always lied — removed the cap so total/hasMore are accurate. The four endpoints whose consumers expect the full set (no load-more) got generous defaults (200) to avoid silent truncation.

Verified by scripts/verify-pagination.ts (18 checks incl. UserSearch total accuracy). All 16 suites green.

Note: committed on branch chore/migrate-text-to-mustache, not main yet.

Sign in to comment on this issue.