Merge pull request #1193 from GSA/notify-api-771b

Notify api 771 fix columns in reports
This commit is contained in:
Carlo Costino
2024-02-16 09:59:32 -05:00
committed by GitHub
2 changed files with 63 additions and 93 deletions

View File

@@ -78,32 +78,29 @@ def generate_notifications_csv(**kwargs):
template=get_sample_template(kwargs["template_type"]),
)
original_column_headers = original_upload.column_headers
fieldnames = (
["Row number"]
+ original_column_headers
+ [
"Template",
"Type",
"Sent by",
"Job",
"Carrier",
"Carrier Response",
"Status",
"Time",
]
)
else:
fieldnames = [
"Recipient",
"Template",
"Type",
"Sent by",
"Job",
"Carrier",
"Batch File",
"Carrier Response",
"Status",
"Time",
]
for header in original_column_headers:
fieldnames.append(header)
else:
# TODO This is deprecated because everything should be a job now, is it ever invoked?
fieldnames = [
"Recipient",
"Template",
"Sent by",
"Batch File",
"Carrier Response",
"Status",
"Time",
]
current_app.logger.warning("Invoking deprecated report format")
yield ",".join(fieldnames) + "\n"
@@ -118,33 +115,26 @@ def generate_notifications_csv(**kwargs):
current_app.logger.info(f"\n\n{notification}")
if kwargs.get("job_id"):
values = (
[
notification["row_number"],
]
+ [
values = [
notification["template_name"],
notification["created_by_name"],
notification["job_name"],
notification["provider_response"],
notification["status"],
preferred_tz_created_at,
]
for header in original_column_headers:
values.append(
original_upload[notification["row_number"] - 1].get(header).data
for header in original_column_headers
]
+ [
notification["template_name"],
notification["template_type"],
notification["created_by_name"],
notification["job_name"],
notification["carrier"],
notification["provider_response"],
notification["status"],
preferred_tz_created_at,
]
)
)
else:
# TODO This is deprecated, should not be invoked. See above
values = [
notification["recipient"],
notification["template_name"],
notification["template_type"],
notification["created_by_name"] or "",
notification["job_name"] or "",
notification["carrier"],
notification["provider_response"],
notification["status"],
preferred_tz_created_at,