mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-06 13:38:25 -04:00
update to support status dropdown
This commit is contained in:
@@ -268,18 +268,23 @@ def get_notifications_for_job(
|
|||||||
|
|
||||||
|
|
||||||
def get_recent_notifications_for_job(
|
def get_recent_notifications_for_job(
|
||||||
service_id, job_id, filter_dict=None, page=1, page_size=None
|
service_id, job_id, filter_dict=None, page=1, page_size=None, status=None
|
||||||
):
|
):
|
||||||
if page_size is None:
|
if page_size is None:
|
||||||
page_size = current_app.config["PAGE_SIZE"]
|
page_size = current_app.config["PAGE_SIZE"]
|
||||||
|
|
||||||
stmt = select(Notification).where(
|
if status is None:
|
||||||
Notification.service_id == service_id,
|
stmt = select(Notification).where(
|
||||||
Notification.job_id == job_id,
|
Notification.service_id == service_id,
|
||||||
Notification.status.in_(
|
Notification.job_id == job_id,
|
||||||
[NotificationStatus.FAILED, NotificationStatus.DELIVERED]
|
)
|
||||||
),
|
else:
|
||||||
)
|
stmt = select(Notification).where(
|
||||||
|
Notification.service_id == service_id,
|
||||||
|
Notification.job_id == job_id,
|
||||||
|
Notification.status == status,
|
||||||
|
)
|
||||||
|
|
||||||
stmt = _filter_query(stmt, filter_dict)
|
stmt = _filter_query(stmt, filter_dict)
|
||||||
stmt = stmt.order_by(desc(Notification.job_row_number))
|
stmt = stmt.order_by(desc(Notification.job_row_number))
|
||||||
print(f"STMT {stmt}")
|
print(f"STMT {stmt}")
|
||||||
|
|||||||
@@ -134,8 +134,14 @@ def get_recent_notifications_for_service_job(service_id, job_id):
|
|||||||
if "page_size" in data
|
if "page_size" in data
|
||||||
else current_app.config.get("PAGE_SIZE")
|
else current_app.config.get("PAGE_SIZE")
|
||||||
)
|
)
|
||||||
|
status = data["status"] if "status" in data else None
|
||||||
paginated_notifications = get_recent_notifications_for_job(
|
paginated_notifications = get_recent_notifications_for_job(
|
||||||
service_id, job_id, filter_dict=data, page=page, page_size=page_size
|
service_id,
|
||||||
|
job_id,
|
||||||
|
filter_dict=data,
|
||||||
|
page=page,
|
||||||
|
page_size=page_size,
|
||||||
|
status=status,
|
||||||
)
|
)
|
||||||
|
|
||||||
kwargs = request.args.to_dict()
|
kwargs = request.args.to_dict()
|
||||||
|
|||||||
Reference in New Issue
Block a user