Skip to content

Commit

Permalink
sparkles: modify get_limit_offset to get_paginated_query_params
Browse files Browse the repository at this point in the history
Signed-off-by: ff137 <[email protected]>
  • Loading branch information
ff137 committed Dec 2, 2024
1 parent 5d6dd46 commit c62b7f5
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions acapy_agent/messaging/models/paginated_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,22 @@ class PaginatedQuerySchema(OpenAPISchema):
)


def get_limit_offset(request: BaseRequest) -> Tuple[int, int]:
"""Read the limit and offset query parameters from a request as ints, with defaults.
def get_paginated_query_params(request: BaseRequest) -> Tuple[int, int, str, bool]:
"""Read the limit, offset, order_by, and descending query parameters from a request.
Args:
request: aiohttp request object
request: aiohttp request object.
Returns:
A tuple of the limit and offset values
A tuple containing:
- limit (int): The number of results to return, defaulting to DEFAULT_PAGE_SIZE.
- offset (int): The offset for pagination, defaulting to 0.
- order_by (str): The field by which to order results, defaulting to "id".
- descending (bool): Whether to order results in descending order, defaulting to False.
"""

limit = int(request.query.get("limit", DEFAULT_PAGE_SIZE))
offset = int(request.query.get("offset", 0))
return limit, offset
order_by = request.query.get("order_by", "id")
descending = bool(request.query.get("descending", False))
return limit, offset, order_by, descending

0 comments on commit c62b7f5

Please sign in to comment.