try cache

This commit is contained in:
Kenneth Kehl
2025-02-20 14:07:55 -08:00
parent f9fd580c58
commit 2dba0015e1
3 changed files with 9 additions and 6 deletions

View File

@@ -65,10 +65,7 @@ def service_dashboard(service_id):
active_jobs = [job for job in job_response if job["job_status"] != "cancelled"]
sorted_jobs = sorted(active_jobs, key=lambda job: job["created_at"], reverse=True)
job_lists = [
{
**job_dict,
"finished_processing": job_is_finished(job_dict)
}
{**job_dict, "finished_processing": job_is_finished(job_dict)}
for job_dict in sorted_jobs
]
@@ -91,7 +88,7 @@ def job_is_finished(job_dict):
"technical-failure",
"temporary-failure",
"permanent-failure",
"cancelled"
"cancelled",
]
processed_count = sum(

View File

@@ -1,10 +1,15 @@
import json
from app.extensions import redis_client
from app.notify_client import NotifyAdminAPIClient, _attach_current_user
from app.notify_client import NotifyAdminAPIClient, _attach_current_user, cache
class NotificationApiClient(NotifyAdminAPIClient):
@cache.set(
"notifications-{service_id}-{job_id}-{status}-{page}-{limit_days}-{include_jobs}-{include_one_off}",
ttl_in_seconds=30,
)
def get_notifications_for_service(
self,
service_id,

View File

@@ -38,6 +38,7 @@ class ServiceAPIClient(NotifyAdminAPIClient):
"""
return self.get("/service/{0}".format(service_id))
@cache.set("service-stats-{service_id}-{limit_days}", ttl_in_seconds=30)
def get_service_statistics(self, service_id, limit_days=None):
return self.get(
"/service/{0}/statistics".format(service_id),