Merge pull request #905 from GSA/notify-api-522

Add carrier to downloadable reports
This commit is contained in:
Carlo Costino
2023-11-03 14:17:23 -04:00
committed by GitHub
2 changed files with 38 additions and 6 deletions

View File

@@ -63,6 +63,7 @@ def generate_notifications_csv(**kwargs):
from app import notification_api_client from app import notification_api_client
from app.s3_client.s3_csv_client import s3download from app.s3_client.s3_csv_client import s3download
current_app.logger.info("\n\n\n\nENTER generate_notifications_csv")
if "page" not in kwargs: if "page" not in kwargs:
kwargs["page"] = 1 kwargs["page"] = 1
@@ -76,7 +77,16 @@ def generate_notifications_csv(**kwargs):
fieldnames = ( fieldnames = (
["Row number"] ["Row number"]
+ original_column_headers + original_column_headers
+ ["Template", "Type", "Sent by", "Job", "Status", "Time"] + [
"Template",
"Type",
"Sent by",
"Job",
"Carrier",
"Carrier Response",
"Status",
"Time",
]
) )
else: else:
fieldnames = [ fieldnames = [
@@ -85,6 +95,8 @@ def generate_notifications_csv(**kwargs):
"Type", "Type",
"Sent by", "Sent by",
"Job", "Job",
"Carrier",
"Carrier Response",
"Status", "Status",
"Time", "Time",
] ]
@@ -96,7 +108,7 @@ def generate_notifications_csv(**kwargs):
**kwargs **kwargs
) )
for notification in notifications_resp["notifications"]: for notification in notifications_resp["notifications"]:
current_app.logger.info(notification) current_app.logger.info(f"\n\n{notification}")
if kwargs.get("job_id"): if kwargs.get("job_id"):
values = ( values = (
[ [
@@ -111,6 +123,8 @@ def generate_notifications_csv(**kwargs):
notification["template_type"], notification["template_type"],
notification["created_by_name"], notification["created_by_name"],
notification["job_name"], notification["job_name"],
notification["carrier"],
notification["provider_response"],
notification["status"], notification["status"],
notification["created_at"], notification["created_at"],
] ]
@@ -122,6 +136,8 @@ def generate_notifications_csv(**kwargs):
notification["template_type"], notification["template_type"],
notification["created_by_name"] or "", notification["created_by_name"] or "",
notification["job_name"] or "", notification["job_name"] or "",
notification["carrier"],
notification["provider_response"],
notification["status"], notification["status"],
notification["created_at"], notification["created_at"],
] ]

View File

@@ -14,6 +14,8 @@ def _get_notifications_csv(
template_name="foo", template_name="foo",
template_type="sms", template_type="sms",
job_name="bar.csv", job_name="bar.csv",
carrier="ATT Mobility",
provider_response="Did not like it",
status="Delivered", status="Delivered",
created_at="1943-04-19 12:00:00", created_at="1943-04-19 12:00:00",
rows=1, rows=1,
@@ -47,6 +49,8 @@ def _get_notifications_csv(
"template_type": template_type, "template_type": template_type,
"template": {"name": template_name, "template_type": template_type}, "template": {"name": template_name, "template_type": template_type},
"job_name": job_name, "job_name": job_name,
"carrier": carrier,
"provider_response": provider_response,
"status": status, "status": status,
"created_at": created_at, "created_at": created_at,
"updated_at": None, "updated_at": None,
@@ -82,15 +86,15 @@ def get_notifications_csv_mock(
( (
None, None,
[ [
"Recipient,Template,Type,Sent by,Job,Status,Time\n", "Recipient,Template,Type,Sent by,Job,Carrier,Carrier Response,Status,Time\n",
"foo@bar.com,foo,sms,,,Delivered,1943-04-19 12:00:00\r\n", "foo@bar.com,foo,sms,,,ATT Mobility,Did not like it,Delivered,1943-04-19 12:00:00\r\n",
], ],
), ),
( (
"Anne Example", "Anne Example",
[ [
"Recipient,Template,Type,Sent by,Job,Status,Time\n", "Recipient,Template,Type,Sent by,Job,Carrier,Carrier Response,Status,Time\n",
"foo@bar.com,foo,sms,Anne Example,,Delivered,1943-04-19 12:00:00\r\n", "foo@bar.com,foo,sms,Anne Example,,ATT Mobility,Did not like it,Delivered,1943-04-19 12:00:00\r\n",
], ],
), ),
], ],
@@ -128,6 +132,8 @@ def test_generate_notifications_csv_without_job(
"Type", "Type",
"Sent by", "Sent by",
"Job", "Job",
"Carrier",
"Carrier Response",
"Status", "Status",
"Time", "Time",
], ],
@@ -138,6 +144,8 @@ def test_generate_notifications_csv_without_job(
"sms", "sms",
"Fake Person", "Fake Person",
"bar.csv", "bar.csv",
"ATT Mobility",
"Did not like it",
"Delivered", "Delivered",
"1943-04-19 12:00:00", "1943-04-19 12:00:00",
], ],
@@ -157,6 +165,8 @@ def test_generate_notifications_csv_without_job(
"Type", "Type",
"Sent by", "Sent by",
"Job", "Job",
"Carrier",
"Carrier Response",
"Status", "Status",
"Time", "Time",
], ],
@@ -170,6 +180,8 @@ def test_generate_notifications_csv_without_job(
"sms", "sms",
"Fake Person", "Fake Person",
"bar.csv", "bar.csv",
"ATT Mobility",
"Did not like it",
"Delivered", "Delivered",
"1943-04-19 12:00:00", "1943-04-19 12:00:00",
], ],
@@ -189,6 +201,8 @@ def test_generate_notifications_csv_without_job(
"Type", "Type",
"Sent by", "Sent by",
"Job", "Job",
"Carrier",
"Carrier Response",
"Status", "Status",
"Time", "Time",
], ],
@@ -202,6 +216,8 @@ def test_generate_notifications_csv_without_job(
"sms", "sms",
"Fake Person", "Fake Person",
"bar.csv", "bar.csv",
"ATT Mobility",
"Did not like it",
"Delivered", "Delivered",
"1943-04-19 12:00:00", "1943-04-19 12:00:00",
], ],