-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pagination support to the API (#211)
## Ticket Resolves #210 ## Changes This adds pagination support to the API schema and DB queries Added a new `POST /users/search` endpoint to have an example of a paginated endpoint. ## Context for reviewers There are likely more features that could be built ontop of this (multi-field sorting, Paginator class as an iterator, and a few other utilities), but was focused on getting the core functionality of pagination working in a fairly general manner. This approach for pagination is based on a mix of past projects and partially based on the [Flask-SQLAlchemy](https://github.com/pallets-eco/flask-sqlalchemy/blob/d349bdb6229fb5893ddfc7a6ff273425e4c1da7a/src/flask_sqlalchemy/pagination.py) libraries approach. ## Testing Added a bunch of users locally by calling the POST /users endpoint, but only one which would be found by the following query: ```json { "is_active": true, "paging": { "page_offset": 1, "page_size": 25 }, "phone_number": "123-456-7890", "role_type": "USER", "sorting": { "order_by": "id", "sort_direction": "ascending" } } ``` And got the following response (with the data removed as it's a lot): ```json { "data": [...], "errors": [], "message": "Success", "pagination_info": { "order_by": "id", "page_offset": 1, "page_size": 25, "sort_direction": "ascending", "total_pages": 2, "total_records": 41 }, "status_code": 200, "warnings": [] } ``` Further testing was done, and can be seen in the unit tests to verify the paging/sorting behavior. --------- Co-authored-by: nava-platform-bot <[email protected]>
- Loading branch information
1 parent
e48e359
commit 670aaa6
Showing
16 changed files
with
773 additions
and
29 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Empty file.
Oops, something went wrong.