fix : pagination_and_Filtering_for_Lists-2 #22
Merged
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.
Hi @sr-857 ,
I refactored the get_analyses endpoint to make it more robust for our frontend integrations and scalable for larger datasets. This update addresses potential performance bottlenecks and improves the developer experience by providing clearer pagination details.
Key Changes:
1.) Smart Pagination: The response now wraps the list of items with metadata (total_count, has_next), so the frontend knows exactly when to show a "Load More" button or how many pages exist.
2.) Performance Safeguards: Implemented a hard limit of 100 items per request. Attempting to fetch more than that now returns a helpful 400 Bad Request instead of silently straining the database.
3.) Consistent Ordering: Fixed potential "page drift" issues. Results are now sorted by created_at and a unique id, guaranteeing that items won't jump around between pages if they have the same timestamp.
4.) Schema Updates: Updated AnalysisListResponse and PaginationMetadata to reflect these changes in our API contract.
Breaking Change:
1.) The response format for GET /analysis has changed:
Before: [ { ...analysis }, ... ]
After: { "items": [ ...analysis ], "metadata": { "total_count": 50, "has_next": true, ... } }
Thanks for the issue assignment. This branch is ready to merge cleanly.
Don't merge this until my next commit or comment, i need to check is there any other change that increase the performance of the system!