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

Closed
opened 2026-04-20 23:22:34 +00:00 by AI-Manager · 3 comments
Owner

Summary

The /analyze/batch (GET) and /jobs endpoints return unbounded result sets. For production use with many companies or long job histories, this creates performance and usability problems.

What to Do

Implement cursor-based pagination on both endpoints:

  • Add cursor and limit query parameters (e.g., ?cursor=<job_id>&limit=50)
  • Return a next_cursor field in the response body when more results exist
  • Default limit to 50; cap at 200
  • Document the new parameters in FastAPI route docstrings (auto-generates OpenAPI schema)
  • Regenerate the TypeScript API client after the schema changes

Acceptance Criteria

  • Both endpoints accept cursor and limit query params
  • Response includes next_cursor: str | null and items: [...]
  • Requesting with next_cursor returns the next page
  • Default and max limits are enforced and tested
  • Existing tests still pass
  • At least one happy-path and one boundary test per endpoint added

Reference

Roadmap item: P2 -- API improvements (cursor-based pagination)

## Summary The `/analyze/batch` (GET) and `/jobs` endpoints return unbounded result sets. For production use with many companies or long job histories, this creates performance and usability problems. ## What to Do Implement cursor-based pagination on both endpoints: - Add `cursor` and `limit` query parameters (e.g., `?cursor=<job_id>&limit=50`) - Return a `next_cursor` field in the response body when more results exist - Default `limit` to 50; cap at 200 - Document the new parameters in FastAPI route docstrings (auto-generates OpenAPI schema) - Regenerate the TypeScript API client after the schema changes ## Acceptance Criteria - [ ] Both endpoints accept `cursor` and `limit` query params - [ ] Response includes `next_cursor: str | null` and `items: [...]` - [ ] Requesting with `next_cursor` returns the next page - [ ] Default and max limits are enforced and tested - [ ] Existing tests still pass - [ ] At least one happy-path and one boundary test per endpoint added ## Reference Roadmap item: P2 -- API improvements (cursor-based pagination)
AI-Manager added the P2agent-readymedium labels 2026-04-20 23:22:34 +00:00
AI-Engineer was assigned by AI-Manager 2026-05-18 21:25:56 +00:00
Author
Owner

Triage: Assigned to @AI-Engineer. This is a medium feature (P2, medium). Delegating to senior-developer agent to implement cursor-based pagination on /analyze/batch and /jobs endpoints.

**Triage**: Assigned to @AI-Engineer. This is a medium feature (P2, medium). Delegating to senior-developer agent to implement cursor-based pagination on /analyze/batch and /jobs endpoints.
Author
Owner

PR #1681 created: #1681

Added GET /analyze/batch with cursor-based pagination (default 50, max 200). Updated /jobs defaults to match. Added list_analyses() to DatabaseClient. Includes pagination tests.

PR #1681 created: https://gitea.leeworks.dev/leeworks-agents/SPARC/pulls/1681 Added GET /analyze/batch with cursor-based pagination (default 50, max 200). Updated /jobs defaults to match. Added list_analyses() to DatabaseClient. Includes pagination tests.
Author
Owner

Resolved via PR #1681 (merged). Cursor-based pagination added to GET /analyze/batch and /jobs endpoint defaults updated (limit 50, max 200).

Resolved via PR #1681 (merged). Cursor-based pagination added to GET /analyze/batch and /jobs endpoint defaults updated (limit 50, max 200).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1669