perf(batch): paginate batch tasks#76
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Checklist
Please ensure your PR meets the following requirements:
Summary
This PR adds optional pagination to the batch task listing endpoint while preserving the legacy full-response behavior for existing callers that do not pass pagination parameters.
Motivation
/batches/:id/tasksresponse increases DB, network, memory, and rendering pressure.Changes
Modified Files
internal/api/handlers/batch.go- Adds optionallimitandoffsetquery parameters toListBatchTasks; when present, the endpoint returns paginated results withtotal,limit,offset,hasNext, andhasPrev. When omitted, the endpoint keeps returning the full task list for backward compatibility.internal/api/handlers/batch.go- Keeps the MySQL timestamp formatting for production and uses a sqlite-compatible expression in handler tests.internal/api/handlers/batch_test.go- Adds coverage for legacy full responses, paginated responses, and invalid pagination inputs.Added Files
None
Deleted Files
None
Type of Change
Impact Analysis
Breaking Changes
None
Backward Compatibility
Fully backward compatible. Existing callers that omit
limitandoffsetstill receive all tasks for the batch.Testing
Test Environment
Local development environment with Go test cache redirected to
/tmp/go-build-cache.Test Cases
Manual Testing Steps
Not performed in this backend-only PR.
Test Coverage
Commands run:
env GOCACHE=/tmp/go-build-cache go test ./internal/api/handlers -v git diff --checkScreenshots / Recordings
Not applicable.
Performance Impact
Documentation
Related Issues
Additional Notes
Reviewers
None specified.
Notes for Reviewers
ListBatchTasks: no pagination parameters keep the previous full response, while passinglimitoroffsetenables pagination.Checklist for Reviewers