feat: add cursor-based pagination for task fetching#80
feat: add cursor-based pagination for task fetching#80realien-OG wants to merge 1 commit intogreirson:mainfrom
Conversation
Add automatic cursor-based pagination to fetch tasks across all pages, eliminating issues where tasks beyond the first page were missed. New functions in api-helpers.ts: - fetchAllPaginated<T>() - generic pagination with 50-page safety limit - fetchAllTasks() - paginated task fetching with optional limit - fetchAllTasksByFilter() - paginated filter queries with optional limit When a limit parameter is provided, it is used as the page size and pagination stops after collecting that many items, preserving the existing single-page behavior for callers that want bounded results. Updated handlers: task/crud.ts, task/bulk.ts Updated resolveProjectIdentifier() to use paginated getProjects() Added shared test mock helper: __tests__/helpers/mock-pagination.ts Added pagination test suite: __tests__/pagination.test.ts (7 tests) Updated 5 existing test files for paginated response format Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Thanks for splitting this out from #76. The A few things need addressing before this can merge: 1. Unbounded pagination is a performance regression (Critical)When no Bulk operations (update/delete/complete) arguably need all tasks to find matches, that's fine. But Please add a default cap (e.g., 200) when no limit is provided. Callers that genuinely need all tasks (bulk ops) should explicitly opt in. 2. Incomplete migration creates inconsistencyOnly Either migrate them, or document in the PR description that this is phase 1 and which files are left. 3. Verify
|
Summary
fetchAllPaginated<T>()generic pagination helper with 50-page safety limitfetchAllTasks()andfetchAllTasksByFilter()convenience wrapperslimitparameter: when provided, used as page size and pagination stops after collecting that many items (no performance regression for bounded queries)resolveProjectIdentifier()to use paginatedgetProjects()src/__tests__/helpers/mock-pagination.ts(eliminates copy-paste across test files)Addresses review feedback from #76
limitparameter preserved —fetchAllTasksByFilter()accepts optional limit; when provided, fetches only that many items instead of all pagesmockPaginatedGetTasks()andmockPaginatedGetTasksByFilter()helpersgetTasksByFilter()(consistent with merged PR fix: remove incorrect client-side @label filtering for getTasksByFilter API #69)Files Changed (10)
src/utils/api-helpers.ts— new pagination functions + updatedresolveProjectIdentifiersrc/handlers/task/crud.ts— usefetchAllTasks/fetchAllTasksByFiltersrc/handlers/task/bulk.ts— usefetchAllTaskssrc/__tests__/helpers/mock-pagination.ts— new shared test helperssrc/__tests__/pagination.test.ts— new test suite (7 tests)Test plan
npm run build— compiles cleannpm test— 429 tests pass (25 suites)npm run lint— 0 errorsExtracted from #76 per review feedback — focused on pagination only.
🤖 Generated with Claude Code