mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-31 23:26:23 -05:00
fix test code
This commit is contained in:
@@ -16,13 +16,15 @@ def save_complaint(complaint):
|
||||
|
||||
|
||||
def fetch_paginated_complaints(page=1):
|
||||
# return Complaint.query.order_by(desc(Complaint.created_at)).paginate(
|
||||
# page=page, per_page=current_app.config["PAGE_SIZE"]
|
||||
# )
|
||||
page_size = current_app.config["PAGE_SIZE"]
|
||||
total_count = db.session.scalar(select(func.count()).select_from(Complaint))
|
||||
offset = (page - 1) * page_size
|
||||
stmt = select(Complaint).order_by(desc(Complaint.created_at)).offset(offset).limit(page_size)
|
||||
stmt = (
|
||||
select(Complaint)
|
||||
.order_by(desc(Complaint.created_at))
|
||||
.offset(offset)
|
||||
.limit(page_size)
|
||||
)
|
||||
result = db.session.execute(stmt).scalars().all()
|
||||
pagination = Pagination(result, page=page, per_page=page_size, total=total_count)
|
||||
return pagination
|
||||
|
||||
Reference in New Issue
Block a user