Optimize DREF3 pagination by appeal_code#2739
Open
szabozoltan69 wants to merge 2 commits into
Open
Conversation
Contributor
Author
|
We switched from sorted(combined) to list(combined) because ordering is now handled later by _order_codes(). That helper applies the default appeal_code sort or the optional order_by=created_at logic, so sorting at the combine step would be redundant and could conflict with order_by. |
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.
This change shifts DREF3 list pagination to operate on appeal_code values before retrieval, so only the requested page of codes is fetched and serialized.
The new _order_codes() helper defaults to sorting by appeal_code, and supports order_by=created_at or order_by=-created_at based on the first DREF application created_at per code. The _paginate_codes() helper applies offset and limit to that ordered code list rather than to the final row list. As a result, page sizes in rows can vary because one code can expand to multiple stage rows. Stage filtering still happens after retrieval, so it can further reduce the number of rows returned in a page.
The OpenAPI schema for the list endpoint now documents the order_by query parameter and its accepted values.
Overall, the endpoint avoids building the full dataset just to slice it, reducing work and memory for typical paged requests.