diff --git a/app/main/views/dashboard.py b/app/main/views/dashboard.py
index 4c70b85fd..4966c0300 100644
--- a/app/main/views/dashboard.py
+++ b/app/main/views/dashboard.py
@@ -1,5 +1,4 @@
import calendar
-from collections import defaultdict
from datetime import datetime
from functools import partial
from itertools import groupby
@@ -13,7 +12,6 @@ from app import (
billing_api_client,
current_service,
job_api_client,
- notification_api_client,
service_api_client,
socketio,
template_statistics_client,
@@ -83,18 +81,9 @@ def service_dashboard(service_id):
return redirect(url_for("main.choose_template", service_id=service_id))
job_response = job_api_client.get_jobs(service_id)["data"]
- notifications_response = notification_api_client.get_notifications_for_service(
- service_id
- )["notifications"]
service_data_retention_days = 7
- aggregate_notifications_by_job = defaultdict(list)
- for notification in notifications_response:
- job_id = notification.get("job", {}).get("id", None)
- if job_id:
- aggregate_notifications_by_job[job_id].append(notification)
-
- job_and_notifications = [
+ jobs = [
{
"job_id": job["id"],
"time_left": get_time_left(job["created_at"]),
@@ -105,20 +94,20 @@ def service_dashboard(service_id):
".view_job", service_id=current_service.id, job_id=job["id"]
),
"created_at": job["created_at"],
- "processing_finished": job["processing_finished"],
- "processing_started": job["processing_started"],
+ "processing_finished": job.get("processing_finished"),
+ "processing_started": job.get("processing_started"),
"notification_count": job["notification_count"],
"created_by": job["created_by"],
- "notifications": aggregate_notifications_by_job.get(job["id"], []),
+ "template_name": job["template_name"],
+ "original_file_name": job["original_file_name"],
}
for job in job_response
- if aggregate_notifications_by_job.get(job["id"], [])
]
return render_template(
"views/dashboard/dashboard.html",
updates_url=url_for(".service_dashboard_updates", service_id=service_id),
partials=get_dashboard_partials(service_id),
- job_and_notifications=job_and_notifications,
+ jobs=jobs,
service_data_retention_days=service_data_retention_days,
)
diff --git a/app/templates/views/dashboard/dashboard.html b/app/templates/views/dashboard/dashboard.html
index aba7d2ac6..e8e5ec633 100644
--- a/app/templates/views/dashboard/dashboard.html
+++ b/app/templates/views/dashboard/dashboard.html
@@ -55,31 +55,30 @@
- {% if job_and_notifications %}
- {% for job in job_and_notifications[:5] %}
- {% if job.job_id and job.notifications %}
+ {% if jobs %}
+ {% for job in jobs[:5] %}
{% set notification = job.notifications[0] %}
- {{ notification.job.original_file_name[:12] if notification.job.original_file_name else 'Manually entered number'}}
+ {{ job.original_file_name[:12] if job.original_file_name else 'Manually entered number'}}
View Batch
|
- {{ notification.template.name }}
+ {{ job.template_name }}
|
{{ (job.processing_finished if job.processing_finished else job.processing_started
if job.processing_started else job.created_at)|format_datetime_table }}
|
- {{ notification.created_by.name }}
+ {{ job.created_by.name }}
|
{{ job.notification_count}}
|
- {% if notification and job.time_left != "Data no longer available" %}
+ {% if job.time_left != "Data no longer available" %}
Download
{{ job.time_left }}
{% elif job %}
@@ -87,7 +86,6 @@
{% endif %}
|
- {% endif %}
{% endfor %}
{% else %}
diff --git a/tests/app/main/views/test_dashboard.py b/tests/app/main/views/test_dashboard.py
index d0d48bffc..bccfa27b4 100644
--- a/tests/app/main/views/test_dashboard.py
+++ b/tests/app/main/views/test_dashboard.py
@@ -305,10 +305,6 @@ def test_inbound_messages_shows_count_of_messages_when_there_are_messages(
mock_get_inbound_sms_summary,
):
service_one["permissions"] = ["inbound_sms"]
- mocker.patch(
- "app.notification_api_client.get_notifications_for_service",
- return_value=FAKE_ONE_OFF_NOTIFICATION,
- )
page = client_request.get(
"main.service_dashboard",
service_id=SERVICE_ONE_ID,
@@ -337,10 +333,6 @@ def test_inbound_messages_shows_count_of_messages_when_there_are_no_messages(
mock_get_inbound_sms_summary_with_no_messages,
):
service_one["permissions"] = ["inbound_sms"]
- mocker.patch(
- "app.notification_api_client.get_notifications_for_service",
- return_value=FAKE_ONE_OFF_NOTIFICATION,
- )
page = client_request.get(
"main.service_dashboard",
service_id=SERVICE_ONE_ID,
@@ -839,10 +831,6 @@ def test_should_not_show_upcoming_jobs_on_dashboard_if_count_is_0(
},
)
mocker.patch("app.job_api_client.get_jobs", return_value=MOCK_JOBS)
- mocker.patch(
- "app.notification_api_client.get_notifications_for_service",
- return_value=FAKE_ONE_OFF_NOTIFICATION,
- )
page = client_request.get(
"main.service_dashboard",
service_id=SERVICE_ONE_ID,
@@ -919,10 +907,6 @@ def test_correct_font_size_for_big_numbers(
mocker.patch("app.main.views.dashboard.get_dashboard_totals", return_value=totals)
mocker.patch("app.job_api_client.get_jobs", return_value=MOCK_JOBS)
- mocker.patch(
- "app.notification_api_client.get_notifications_for_service",
- return_value=FAKE_ONE_OFF_NOTIFICATION,
- )
page = client_request.get(
"main.service_dashboard",
service_id=service_one["id"],
@@ -952,10 +936,6 @@ def test_should_not_show_jobs_on_dashboard_for_users_with_uploads_page(
mock_get_free_sms_fragment_limit,
mock_get_inbound_sms_summary,
):
- mocker.patch(
- "app.notification_api_client.get_notifications_for_service",
- return_value=FAKE_ONE_OFF_NOTIFICATION,
- )
page = client_request.get(
"main.service_dashboard",
service_id=SERVICE_ONE_ID,