mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-28 10:13:59 -04:00
Compare commits
3 Commits
1bf55e7fa3
...
fix-endles
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
96c2b7f419 | ||
|
|
b77749415f | ||
|
|
2dba0015e1 |
@@ -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),
|
||||||
|
|||||||
@@ -55,8 +55,16 @@ from app.notify_client.notification_api_client import NotificationApiClient
|
|||||||
def test_client_gets_notifications_for_service_and_job_by_page(
|
def test_client_gets_notifications_for_service_and_job_by_page(
|
||||||
mocker, arguments, expected_call
|
mocker, arguments, expected_call
|
||||||
):
|
):
|
||||||
|
|
||||||
|
mocker.patch(
|
||||||
|
"app.extensions.RedisClient.get",
|
||||||
|
return_value={},
|
||||||
|
)
|
||||||
|
|
||||||
|
mocker.patch("app.extensions.RedisClient.set", return_value={})
|
||||||
mock_get = mocker.patch(
|
mock_get = mocker.patch(
|
||||||
"app.notify_client.notification_api_client.NotificationApiClient.get"
|
"app.notify_client.notification_api_client.NotificationApiClient.get",
|
||||||
|
return_value={},
|
||||||
)
|
)
|
||||||
NotificationApiClient().get_notifications_for_service("abcd1234", **arguments)
|
NotificationApiClient().get_notifications_for_service("abcd1234", **arguments)
|
||||||
mock_get.assert_called_once_with(**expected_call)
|
mock_get.assert_called_once_with(**expected_call)
|
||||||
@@ -102,8 +110,16 @@ def test_client_gets_notifications_for_service_and_job_by_page(
|
|||||||
def test_client_gets_notifications_for_service_and_job_by_page_posts_for_to(
|
def test_client_gets_notifications_for_service_and_job_by_page_posts_for_to(
|
||||||
mocker, arguments, expected_call
|
mocker, arguments, expected_call
|
||||||
):
|
):
|
||||||
|
|
||||||
|
mocker.patch(
|
||||||
|
"app.extensions.RedisClient.get",
|
||||||
|
return_value={},
|
||||||
|
)
|
||||||
|
|
||||||
|
mocker.patch("app.extensions.RedisClient.set", return_value={})
|
||||||
mock_post = mocker.patch(
|
mock_post = mocker.patch(
|
||||||
"app.notify_client.notification_api_client.NotificationApiClient.post"
|
"app.notify_client.notification_api_client.NotificationApiClient.post",
|
||||||
|
return_value={},
|
||||||
)
|
)
|
||||||
NotificationApiClient().get_notifications_for_service("abcd1234", **arguments)
|
NotificationApiClient().get_notifications_for_service("abcd1234", **arguments)
|
||||||
mock_post.assert_called_once_with(**expected_call)
|
mock_post.assert_called_once_with(**expected_call)
|
||||||
|
|||||||
Reference in New Issue
Block a user