mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-24 16:24:08 -04:00
change batch file report to look like full csv report
This commit is contained in:
@@ -49,7 +49,9 @@ def service_dashboard(service_id):
|
|||||||
return redirect(url_for("main.choose_template", service_id=service_id))
|
return redirect(url_for("main.choose_template", service_id=service_id))
|
||||||
|
|
||||||
job_response = job_api_client.get_jobs(service_id)["data"]
|
job_response = job_api_client.get_jobs(service_id)["data"]
|
||||||
notifications_response = notification_api_client.get_notifications_for_service(service_id)["notifications"]
|
notifications_response = notification_api_client.get_notifications_for_service(
|
||||||
|
service_id
|
||||||
|
)["notifications"]
|
||||||
service_data_retention_days = 7
|
service_data_retention_days = 7
|
||||||
|
|
||||||
aggregate_notifications_by_job = defaultdict(list)
|
aggregate_notifications_by_job = defaultdict(list)
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ def generate_notifications_csv(**kwargs):
|
|||||||
)
|
)
|
||||||
original_column_headers = original_upload.column_headers
|
original_column_headers = original_upload.column_headers
|
||||||
fieldnames = [
|
fieldnames = [
|
||||||
|
"Recipient",
|
||||||
"Template",
|
"Template",
|
||||||
"Sent by",
|
"Sent by",
|
||||||
"Batch File",
|
"Batch File",
|
||||||
@@ -87,7 +88,8 @@ def generate_notifications_csv(**kwargs):
|
|||||||
"Time",
|
"Time",
|
||||||
]
|
]
|
||||||
for header in original_column_headers:
|
for header in original_column_headers:
|
||||||
fieldnames.append(header)
|
if header.lower() != "phone number":
|
||||||
|
fieldnames.append(header)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# TODO This is deprecated because everything should be a job now, is it ever invoked?
|
# TODO This is deprecated because everything should be a job now, is it ever invoked?
|
||||||
@@ -113,9 +115,9 @@ def generate_notifications_csv(**kwargs):
|
|||||||
notification["created_at"]
|
notification["created_at"]
|
||||||
)
|
)
|
||||||
|
|
||||||
current_app.logger.info(f"\n\n{notification}")
|
|
||||||
if kwargs.get("job_id"):
|
if kwargs.get("job_id"):
|
||||||
values = [
|
values = [
|
||||||
|
notification["recipient"],
|
||||||
notification["template_name"],
|
notification["template_name"],
|
||||||
notification["created_by_name"],
|
notification["created_by_name"],
|
||||||
notification["job_name"],
|
notification["job_name"],
|
||||||
@@ -124,12 +126,14 @@ def generate_notifications_csv(**kwargs):
|
|||||||
preferred_tz_created_at,
|
preferred_tz_created_at,
|
||||||
]
|
]
|
||||||
for header in original_column_headers:
|
for header in original_column_headers:
|
||||||
values.append(
|
if header.lower() != "phone number":
|
||||||
original_upload[notification["row_number"] - 1].get(header).data
|
values.append(
|
||||||
)
|
original_upload[notification["row_number"] - 1]
|
||||||
|
.get(header)
|
||||||
|
.data
|
||||||
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# TODO This is deprecated, should not be invoked. See above
|
|
||||||
values = [
|
values = [
|
||||||
notification["recipient"],
|
notification["recipient"],
|
||||||
notification["template_name"],
|
notification["template_name"],
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ MOCK_JOBS_AND_NOTIFICATIONS = [
|
|||||||
"notification_count": MOCK_JOBS["data"][0]["notification_count"],
|
"notification_count": MOCK_JOBS["data"][0]["notification_count"],
|
||||||
"notifications": FAKE_ONE_OFF_NOTIFICATION["notifications"],
|
"notifications": FAKE_ONE_OFF_NOTIFICATION["notifications"],
|
||||||
"time_left": "Data available for 7 days",
|
"time_left": "Data available for 7 days",
|
||||||
"view_job_link": "/services/21b3ee3d-1cb0-4666-bfa0-9c5ac26d3fe3/jobs/463b5ecb-4e32-43e5-aa90-0234d19fceaa"
|
"view_job_link": "/services/21b3ee3d-1cb0-4666-bfa0-9c5ac26d3fe3/jobs/463b5ecb-4e32-43e5-aa90-0234d19fceaa",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ from tests.conftest import fake_uuid
|
|||||||
|
|
||||||
def _get_notifications_csv(
|
def _get_notifications_csv(
|
||||||
row_number=1,
|
row_number=1,
|
||||||
recipient="foo@bar.com",
|
recipient="2028675309",
|
||||||
template_name="foo",
|
template_name="foo",
|
||||||
template_type="sms",
|
template_type="sms",
|
||||||
job_name="bar.csv",
|
job_name="bar.csv",
|
||||||
@@ -89,14 +89,14 @@ def get_notifications_csv_mock(
|
|||||||
None,
|
None,
|
||||||
[
|
[
|
||||||
"Recipient,Template,Sent by,Batch File,Carrier Response,Status,Time\n",
|
"Recipient,Template,Sent by,Batch File,Carrier Response,Status,Time\n",
|
||||||
"foo@bar.com,foo,,,Did not like it,Delivered,1943-04-19 08:00:00 AM US/Eastern\r\n",
|
"2028675309,foo,,,Did not like it,Delivered,1943-04-19 08:00:00 AM US/Eastern\r\n",
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"Anne Example",
|
"Anne Example",
|
||||||
[
|
[
|
||||||
"Recipient,Template,Sent by,Batch File,Carrier Response,Status,Time\n",
|
"Recipient,Template,Sent by,Batch File,Carrier Response,Status,Time\n",
|
||||||
"foo@bar.com,foo,Anne Example,,Did not like it,Delivered,1943-04-19 08:00:00 AM US/Eastern\r\n", # noqa
|
"2028675309,foo,Anne Example,,Did not like it,Delivered,1943-04-19 08:00:00 AM US/Eastern\r\n", # noqa
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -124,53 +124,53 @@ def test_generate_notifications_csv_without_job(
|
|||||||
[
|
[
|
||||||
(
|
(
|
||||||
"""
|
"""
|
||||||
phone_number
|
phone number
|
||||||
2028675309
|
2028675309
|
||||||
""",
|
""",
|
||||||
[
|
[
|
||||||
|
"Recipient",
|
||||||
"Template",
|
"Template",
|
||||||
"Sent by",
|
"Sent by",
|
||||||
"Batch File",
|
"Batch File",
|
||||||
"Carrier Response",
|
"Carrier Response",
|
||||||
"Status",
|
"Status",
|
||||||
"Time",
|
"Time",
|
||||||
"phone_number",
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
"2028675309",
|
||||||
"foo",
|
"foo",
|
||||||
"Fake Person",
|
"Fake Person",
|
||||||
"bar.csv",
|
"bar.csv",
|
||||||
"Did not like it",
|
"Did not like it",
|
||||||
"Delivered",
|
"Delivered",
|
||||||
"1943-04-19 08:00:00 AM US/Eastern",
|
"1943-04-19 08:00:00 AM US/Eastern",
|
||||||
"2028675309",
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"""
|
"""
|
||||||
phone_number, a, b, c
|
phone number, a, b, c
|
||||||
2028675309, 🐜,🐝,🦀
|
2028675309, 🐜,🐝,🦀
|
||||||
""",
|
""",
|
||||||
[
|
[
|
||||||
|
"Recipient",
|
||||||
"Template",
|
"Template",
|
||||||
"Sent by",
|
"Sent by",
|
||||||
"Batch File",
|
"Batch File",
|
||||||
"Carrier Response",
|
"Carrier Response",
|
||||||
"Status",
|
"Status",
|
||||||
"Time",
|
"Time",
|
||||||
"phone_number",
|
|
||||||
"a",
|
"a",
|
||||||
"b",
|
"b",
|
||||||
"c",
|
"c",
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
"2028675309",
|
||||||
"foo",
|
"foo",
|
||||||
"Fake Person",
|
"Fake Person",
|
||||||
"bar.csv",
|
"bar.csv",
|
||||||
"Did not like it",
|
"Did not like it",
|
||||||
"Delivered",
|
"Delivered",
|
||||||
"1943-04-19 08:00:00 AM US/Eastern",
|
"1943-04-19 08:00:00 AM US/Eastern",
|
||||||
"2028675309",
|
|
||||||
"🐜",
|
"🐜",
|
||||||
"🐝",
|
"🐝",
|
||||||
"🦀",
|
"🦀",
|
||||||
@@ -178,29 +178,29 @@ def test_generate_notifications_csv_without_job(
|
|||||||
),
|
),
|
||||||
(
|
(
|
||||||
"""
|
"""
|
||||||
"phone_number", "a", "b", "c"
|
"phone number", "a", "b", "c"
|
||||||
"2028675309","🐜,🐜","🐝,🐝","🦀"
|
"2028675309","🐜,🐜","🐝,🐝","🦀"
|
||||||
""",
|
""",
|
||||||
[
|
[
|
||||||
|
"Recipient",
|
||||||
"Template",
|
"Template",
|
||||||
"Sent by",
|
"Sent by",
|
||||||
"Batch File",
|
"Batch File",
|
||||||
"Carrier Response",
|
"Carrier Response",
|
||||||
"Status",
|
"Status",
|
||||||
"Time",
|
"Time",
|
||||||
"phone_number",
|
|
||||||
"a",
|
"a",
|
||||||
"b",
|
"b",
|
||||||
"c",
|
"c",
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
"2028675309",
|
||||||
"foo",
|
"foo",
|
||||||
"Fake Person",
|
"Fake Person",
|
||||||
"bar.csv",
|
"bar.csv",
|
||||||
"Did not like it",
|
"Did not like it",
|
||||||
"Delivered",
|
"Delivered",
|
||||||
"1943-04-19 08:00:00 AM US/Eastern",
|
"1943-04-19 08:00:00 AM US/Eastern",
|
||||||
"2028675309",
|
|
||||||
"🐜,🐜",
|
"🐜,🐜",
|
||||||
"🐝,🐝",
|
"🐝,🐝",
|
||||||
"🦀",
|
"🦀",
|
||||||
|
|||||||
Reference in New Issue
Block a user