mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-11 10:28:55 -04:00
fix first paginate method
This commit is contained in:
@@ -52,11 +52,17 @@ def dao_get_paginated_inbound_sms_for_service_for_public_api(
|
|||||||
)
|
)
|
||||||
filters.append(InboundSms.created_at < older_than_created_at)
|
filters.append(InboundSms.created_at < older_than_created_at)
|
||||||
|
|
||||||
query = InboundSms.query.filter(*filters)
|
# As part of the move to sqlalchemy 2.0, we do this manual pagination
|
||||||
|
# 1.4 had a paginate() method which assumed 'page' was 1 if it was not specified,
|
||||||
return (
|
# so we set page to 1 here to mimic that.
|
||||||
query.order_by(desc(InboundSms.created_at)).paginate(per_page=page_size).items
|
page = 1
|
||||||
|
query = db.session.query(InboundSms).filter(*filters)
|
||||||
|
paginated_items = (
|
||||||
|
query.order_by(desc(InboundSms.created_at))
|
||||||
|
.offset((page - 1) * page_size)
|
||||||
|
.limit(page_size)
|
||||||
)
|
)
|
||||||
|
return paginated_items
|
||||||
|
|
||||||
|
|
||||||
def dao_count_inbound_sms_for_service(service_id, limit_days):
|
def dao_count_inbound_sms_for_service(service_id, limit_days):
|
||||||
|
|||||||
Reference in New Issue
Block a user