-
Notifications
You must be signed in to change notification settings - Fork 21
Description
Ticket Contents
Description
The project already has implementation for pagination using Open/Closed principle using Blacksheep's Binder class. By subclassing using Binder, pagination can be given a definition:
class PageOptionsBinder(Binder):
"""
Binds common pagination options for all endpoints implementing pagination of
results. Collects and validates optional the following query parameters:
- page, for page number
- limit, for results per page
- continuation_id, the last numeric ID that was read
"""
Currently this is consumed by OpenAPI docs as:
def set_binders_docs(docs: OpenAPIHandler):
"""
This function configures OpenAPI Documentation for custom application binders.
"""
This is an application IO specific logic and as such xcov19/domain/common.py
should belong under xcov19/app
as it will be utilized by controller routes. By reusing such extensivle reusable stateless logic for pagination and keeping it within the IO services bound module, the code becomes cleaner and easier to understand and does not confuse with the purpose of domain modulle.
Goals
Goals
- Move
xcov19/domain/common.py
toxcov19/app/common.py
Expected Outcome
Routes including openapi docs can utilize a centralized utility function for pagination.
Acceptance Criteria
- Existing and future controller routes can utilize the same pagination binder class.
- It should not introduce any side-effect or change in existing pagination behaviour.
Implementation Details
This is a refactor and using a modern IDE, moving to a new location should automatically update the imports.
Mockups/Wireframes
No response
Product Name
project-healthcare
Organisation Name
XCoV19
Domain
Healthcare
Tech Skills Needed
Python, RESTful APIs, Flask, Docker
Mentor(s)
Complexity
Medium
Category
Backend, Maintenance