mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 18:01:08 -05:00
fix first paginate method
This commit is contained in:
@@ -197,7 +197,7 @@ def dao_get_paginated_most_recent_inbound_sms_by_user_number_for_service(
|
|||||||
"""
|
"""
|
||||||
t2 = aliased(InboundSms)
|
t2 = aliased(InboundSms)
|
||||||
q = (
|
q = (
|
||||||
db.session.query(InboundSms)
|
select(InboundSms)
|
||||||
.outerjoin(
|
.outerjoin(
|
||||||
t2,
|
t2,
|
||||||
and_(
|
and_(
|
||||||
@@ -206,12 +206,15 @@ def dao_get_paginated_most_recent_inbound_sms_by_user_number_for_service(
|
|||||||
InboundSms.created_at < t2.created_at,
|
InboundSms.created_at < t2.created_at,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.filter(
|
.where(
|
||||||
t2.id == None, # noqa
|
t2.id.is_(None), # noqa
|
||||||
InboundSms.service_id == service_id,
|
InboundSms.service_id == service_id,
|
||||||
InboundSms.created_at >= midnight_n_days_ago(limit_days),
|
InboundSms.created_at >= midnight_n_days_ago(limit_days),
|
||||||
)
|
)
|
||||||
.order_by(InboundSms.created_at.desc())
|
.order_by(InboundSms.created_at.desc())
|
||||||
)
|
)
|
||||||
|
result = db.session.execute(q).scalars().all()
|
||||||
return q.paginate(page=page, per_page=current_app.config["PAGE_SIZE"])
|
page_size = current_app.config["PAGE_SIZE"]
|
||||||
|
offset = (page - 1) * page_size
|
||||||
|
paginated_results = result[offset : offset + page_size]
|
||||||
|
return paginated_results
|
||||||
|
|||||||
Reference in New Issue
Block a user