mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 23:55:58 -05:00
Return template type in uploads response
We need template type for the uploads response, which will eventually supercede the jobs response. At the moment the page uses both.
This commit is contained in:
@@ -25,11 +25,14 @@ def dao_get_uploads_by_service_id(service_id, limit_days=None, page=1, page_size
|
||||
Job.id,
|
||||
Job.original_file_name,
|
||||
Job.notification_count,
|
||||
Template.template_type,
|
||||
Job.created_at.label("created_at"),
|
||||
Job.scheduled_for.label("scheduled_for"),
|
||||
Job.processing_started.label('processing_started'),
|
||||
Job.job_status.label("status"),
|
||||
literal('job').label('upload_type')
|
||||
).join(
|
||||
Template, Job.template_id == Template.id
|
||||
).filter(
|
||||
*jobs_query_filter
|
||||
)
|
||||
@@ -49,6 +52,7 @@ def dao_get_uploads_by_service_id(service_id, limit_days=None, page=1, page_size
|
||||
Notification.id,
|
||||
Notification.client_reference.label('original_file_name'),
|
||||
literal('1').label('notification_count'),
|
||||
literal(None).label('template_type'),
|
||||
Notification.created_at.label("created_at"),
|
||||
literal(None).label('scheduled_for'),
|
||||
# letters don't have a processing_started date but we want created_at to be used for sorting
|
||||
|
||||
@@ -43,7 +43,8 @@ def get_paginated_uploads(service_id, limit_days, page):
|
||||
'notification_count': upload.notification_count,
|
||||
'created_at': upload.scheduled_for.strftime(
|
||||
"%Y-%m-%d %H:%M:%S") if upload.scheduled_for else upload.created_at.strftime("%Y-%m-%d %H:%M:%S"),
|
||||
'upload_type': upload.upload_type
|
||||
'upload_type': upload.upload_type,
|
||||
'template_type': None,
|
||||
}
|
||||
if upload.upload_type == 'job':
|
||||
start = upload.processing_started
|
||||
@@ -58,6 +59,7 @@ def get_paginated_uploads(service_id, limit_days, page):
|
||||
statistics = dao_get_notification_outcomes_for_job(service_id, upload.id)
|
||||
upload_dict['statistics'] = [{'status': statistic.status, 'count': statistic.count} for statistic in
|
||||
statistics]
|
||||
upload_dict['template_type'] = upload.template_type
|
||||
else:
|
||||
upload_dict['statistics'] = [{'status': upload.status, 'count': 1}]
|
||||
data.append(upload_dict)
|
||||
|
||||
Reference in New Issue
Block a user