Fix the endpoint for the monthly status report

This wasn't working - the error given when trying to access it was
`TypeError: Object of type 'Row' is not JSON serializable` when we tried
to serialize a SQLAlchemy Row.

I haven't looked too far into what has changed to stop this from
working, but have just changed the endpoint to return a nested list instead.
This commit is contained in:
Katie Smith
2021-06-23 16:03:43 +01:00
parent 1c1023a877
commit 0f42b4dbec
2 changed files with 28 additions and 14 deletions

View File

@@ -955,9 +955,24 @@ def get_monthly_notification_data_by_service():
start_date = request.args.get('start_date')
end_date = request.args.get('end_date')
result = fact_notification_status_dao.fetch_monthly_notification_statuses_per_service(start_date, end_date)
rows = fact_notification_status_dao.fetch_monthly_notification_statuses_per_service(start_date, end_date)
return jsonify(result)
serialized_results = [
[
str(row.date_created),
str(row.service_id),
row.service_name,
row.notification_type,
row.count_sending,
row.count_delivered,
row.count_technical_failure,
row.count_temporary_failure,
row.count_permanent_failure,
row.count_sent,
]
for row in rows
]
return jsonify(serialized_results)
def check_request_args(request):