Add cursor-based pagination to /analyze/batch and /jobs endpoints #1693

Open
AI-Manager wants to merge 1 commits from feature/1684-cursor-pagination into main
Owner

Summary

Fixes issue #1684. Adds cursor-based pagination to GET /analyze/batch and GET /jobs endpoints, updates the TypeScript API client, and expands the test suite.

Changes

  • Bug fix: GET /analyze/batch was incorrectly shadowed by GET /analyze/{company_name} due to route registration order. Moved GET /analyze/batch to be registered first so requests are routed correctly.
  • TypeScript schema.d.ts: Added AnalysisRecord, PaginatedAnalysisResponse, PaginatedJobsResponse schemas; added GET /analyze/batch operation with cursor, limit, and company_name params; updated list_jobs_jobs_get to include cursor param and return PaginatedJobsResponse.
  • TypeScript client.ts: Added listBatchAnalyses(companyName?, limit?, cursor?) method; updated listJobs() to accept cursor and return PaginatedJobsResponse; default limit updated from 10 to 50.
  • types/index.ts: Exported AnalysisRecord, PaginatedAnalysisResponse, PaginatedJobsResponse.
  • tests/test_pagination.py: Fixed tests to use JWT auth headers; added 11 new /jobs tests covering first page, last page, subsequent pages, empty results, status filter, limit boundaries, cursor forwarding, and paginated response shape.

Acceptance Criteria Met

  • GET /jobs?limit=10 returns at most 10 results with a next_cursor
  • GET /jobs?cursor=<token>&limit=10 returns the next page
  • Last page returns null next_cursor
  • Default limit is 50; max is 200 (validated)
  • TypeScript client updated with new parameters and paginated response types
  • Tests cover: first page, subsequent pages, empty result, limit boundary (0, 201, 200)
  • 20/20 pagination tests pass

Closes leeworks-agents/SPARC#1684

## Summary Fixes issue #1684. Adds cursor-based pagination to `GET /analyze/batch` and `GET /jobs` endpoints, updates the TypeScript API client, and expands the test suite. ### Changes - **Bug fix**: `GET /analyze/batch` was incorrectly shadowed by `GET /analyze/{company_name}` due to route registration order. Moved `GET /analyze/batch` to be registered first so requests are routed correctly. - **TypeScript `schema.d.ts`**: Added `AnalysisRecord`, `PaginatedAnalysisResponse`, `PaginatedJobsResponse` schemas; added `GET /analyze/batch` operation with `cursor`, `limit`, and `company_name` params; updated `list_jobs_jobs_get` to include `cursor` param and return `PaginatedJobsResponse`. - **TypeScript `client.ts`**: Added `listBatchAnalyses(companyName?, limit?, cursor?)` method; updated `listJobs()` to accept `cursor` and return `PaginatedJobsResponse`; default limit updated from 10 to 50. - **`types/index.ts`**: Exported `AnalysisRecord`, `PaginatedAnalysisResponse`, `PaginatedJobsResponse`. - **`tests/test_pagination.py`**: Fixed tests to use JWT auth headers; added 11 new `/jobs` tests covering first page, last page, subsequent pages, empty results, status filter, limit boundaries, cursor forwarding, and paginated response shape. ## Acceptance Criteria Met - `GET /jobs?limit=10` returns at most 10 results with a `next_cursor` - `GET /jobs?cursor=<token>&limit=10` returns the next page - Last page returns null `next_cursor` - Default limit is 50; max is 200 (validated) - TypeScript client updated with new parameters and paginated response types - Tests cover: first page, subsequent pages, empty result, limit boundary (0, 201, 200) - 20/20 pagination tests pass Closes leeworks-agents/SPARC#1684
AI-Manager added 1 commit 2026-05-19 15:38:50 +00:00
- Fix route ordering bug: GET /analyze/batch was shadowed by
  GET /analyze/{company_name} causing all GET requests to /analyze/batch
  to be erroneously handled as single-company analysis (503). Move
  /analyze/batch GET registration to before the {company_name} route.
- Update TypeScript schema.d.ts: add AnalysisRecord, PaginatedAnalysisResponse,
  PaginatedJobsResponse schemas; add GET /analyze/batch operation with
  cursor+limit+company_name params; update list_jobs_jobs_get to include
  cursor param and return PaginatedJobsResponse.
- Update frontend/src/api/client.ts: add listBatchAnalyses() method with
  cursor/limit support; update listJobs() to accept cursor and return
  PaginatedJobsResponse; default limit changed from 10 to 50.
- Update frontend/src/types/index.ts: export AnalysisRecord,
  PaginatedAnalysisResponse, PaginatedJobsResponse.
- Expand tests/test_pagination.py: add auth fixture so tests pass JWT
  validation; add 11 new /jobs tests covering first page, last page,
  subsequent pages, empty results, status filter, limit boundaries, cursor
  forwarding, and paginated response shape.

Closes leeworks-agents/SPARC#1684

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feature/1684-cursor-pagination:feature/1684-cursor-pagination
git checkout feature/1684-cursor-pagination
Sign in to join this conversation.