mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-24 16:24:08 -04: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"]
|
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)
|
sorted_jobs = sorted(active_jobs, key=lambda job: job["created_at"], reverse=True)
|
||||||
job_lists = [
|
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
|
for job_dict in sorted_jobs
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -91,7 +88,7 @@ def job_is_finished(job_dict):
|
|||||||
"technical-failure",
|
"technical-failure",
|
||||||
"temporary-failure",
|
"temporary-failure",
|
||||||
"permanent-failure",
|
"permanent-failure",
|
||||||
"cancelled"
|
"cancelled",
|
||||||
]
|
]
|
||||||
|
|
||||||
processed_count = sum(
|
processed_count = sum(
|
||||||
|
|||||||
@@ -1,10 +1,15 @@
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
from app.extensions import redis_client
|
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):
|
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(
|
def get_notifications_for_service(
|
||||||
self,
|
self,
|
||||||
service_id,
|
service_id,
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ class ServiceAPIClient(NotifyAdminAPIClient):
|
|||||||
"""
|
"""
|
||||||
return self.get("/service/{0}".format(service_id))
|
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):
|
def get_service_statistics(self, service_id, limit_days=None):
|
||||||
return self.get(
|
return self.get(
|
||||||
"/service/{0}/statistics".format(service_id),
|
"/service/{0}/statistics".format(service_id),
|
||||||
|
|||||||
Reference in New Issue
Block a user