Merge branch 'main' of https://github.com/GSA/notifications-admin into 1484-dashboard-visualizations

# Conflicts:
#	app/assets/sass/uswds/_uswds-theme-custom-styles.scss
#	app/templates/views/dashboard/dashboard.html
#	gulpfile.js
#	tests/app/main/views/test_dashboard.py
This commit is contained in:
Jonathan Bobel
2024-07-30 10:45:53 -04:00
44 changed files with 362 additions and 343 deletions

View File

@@ -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,
@@ -94,18 +92,9 @@ def service_dashboard(service_id):
sms_allowance_remaining = usage_data["sms_allowance_remaining"]
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"]),
@@ -116,20 +105,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,
sms_sent=sms_sent,
sms_allowance_remaining=sms_allowance_remaining,