Add keyset pagination for project/issues endpoint
Add Keyset Pagination to Project Issues API Endpoint
What does this MR do and why?
This MR adds keyset-based pagination support to the project issues API endpoint (GET /projects/:id/issues). Keyset pagination provides more efficient and stable pagination compared to offset-based pagination, especially for large datasets.
Key Changes
- Adds keyset pagination support for the project issues endpoint
- Supports ordering by: id,title,created_at,updated_at,due_date,relative_position, andweight
- Excludes complex order options that require table joins: label_priority,popularity,milestone_due, andpriority
- Falls back to offset pagination for unsupported ordering options
Implementation Details
- 
Model Changes ( app/models/issue.rb):- Added supported_keyset_orderingsclass method defining which fields support keyset pagination
 
- Added 
- 
API Changes ( lib/api/issues.rb):- Added cursorparameter support for keyset pagination
- Uses paginate_with_strategiesto handle both keyset and offset pagination
- Automatically falls back to offset pagination for unsupported order options
 
- Added 
- 
Documentation Updates ( doc/api/issues.md,doc/api/rest/_index.md):- Added cursorparameter documentation
- Updated REST API index to include project issues in the list of keyset-paginated endpoints
 
- Added 
References
https://gitlab.com/gitlab-com/gl-infra/production-engineering/-/issues/26555
Screenshots or screen recordings
| Before | After | 
|---|---|
How to set up and validate locally
- 
Make a request to the project issues endpoint with keyset pagination: curl -H "PRIVATE-TOKEN: your-token" \ "http://localhost:3000/api/v4/projects/1/issues?pagination=keyset&per_page=2&order_by=created_at"
- 
Check the response headers for the Linkheader containing the cursor:Link: <http://localhost:3000/api/v4/projects/1/issues?pagination=keyset&per_page=2&order_by=created_at&cursor=eyJjcmVhdGVkX2F0IjoiMjAyNC0wMS0wMSIsImlkIjoxMjM0fQ%3D%3D>; rel="next"
- 
Use the cursor from the Link header in the next request: curl -H "PRIVATE-TOKEN: your-token" \ "http://localhost:3000/api/v4/projects/1/issues?pagination=keyset&per_page=2&order_by=created_at&cursor=eyJjcmVhdGVkX2F0IjoiMjAyNC0wMS0wMSIsImlkIjoxMjM0fQ%3D%3D"
- 
Verify that: - Different pages of results are returned
- The cursor changes between requests
- No cursor is returned on the last page
- Unsupported order options (like label_priority) fall back to offset pagination
 
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.