updated dashboard

This commit is contained in:
Beverly Nguyen
2024-01-08 14:53:34 -08:00
parent 751947c421
commit ec1d9a49bf
4 changed files with 383 additions and 22 deletions

View File

@@ -50,34 +50,52 @@ def service_dashboard(service_id):
notifications = notification_api_client.get_notifications_for_service(
service_id=service_id,
)['notifications']
)["notifications"]
notificaton_job_ids = [notification['job']['id'] for notification in notifications if 'job' in notification]
notificaton_job_ids = [
notification["job"]["id"]
for notification in notifications
if "job" in notification
]
jobs = []
for notificaton_job_id in notificaton_job_ids:
job_data = job_api_client.get_job(service_id, notificaton_job_id)["data"]
jobs.append(job_data)
if job_data:
jobs.append(job_data)
service_data_retention_days = None
download_availability = []
for job in jobs:
message_type = job.get('template_type')
message_type = job.get("template_type")
if message_type is not None:
service_data_retention_days = current_service.get_days_of_retention(message_type)
time_left = get_time_left(job['created_at'], service_data_retention_days=service_data_retention_days)
download_availability.append({"job_id": job['id'], "time_left": time_left})
service_data_retention_days = current_service.get_days_of_retention(
message_type
)
time_left = get_time_left(job["created_at"])
download_link = (
url_for(
".view_job_csv",
service_id=current_service.id,
job_id=job["id"],
),
)
download_availability.append(
{
"job_id": job["id"],
"time_left": time_left,
"download_link": download_link,
}
)
return render_template(
"views/dashboard/dashboard.html",
updates_url=url_for(".service_dashboard_updates", service_id=service_id),
partials=get_dashboard_partials(service_id),
notifications=notifications,
download_availability=download_availability,
service_data_retention_days=service_data_retention_days
)
service_data_retention_days=service_data_retention_days,
)
@main.route("/services/<uuid:service_id>/dashboard.json")