mirror of
https://github.com/GSA/notifications-admin.git
synced 2025-12-11 15:43:45 -05:00
try cache
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user