mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 05:59:44 -04:00
Automate counting of live services and orgs
Returns the data calculated by the API. Stored in Redis against a hardcoded key so that no-one hammering the home page is directly hitting the database.
This commit is contained in:
@@ -25,6 +25,7 @@ class OrganisationsClient(NotifyAdminAPIClient):
|
||||
return self.get(url="/service/{}/organisation".format(service_id))
|
||||
|
||||
@cache.delete('service-{service_id}')
|
||||
@cache.delete('live-service-and-organisation-counts')
|
||||
def update_service_organisation(self, service_id, org_id):
|
||||
data = {
|
||||
'service_id': service_id
|
||||
|
||||
@@ -98,6 +98,14 @@ class ServiceAPIClient(NotifyAdminAPIClient):
|
||||
endpoint = "/service/{0}".format(service_id)
|
||||
return self.post(endpoint, data)
|
||||
|
||||
@cache.delete('live-service-and-organisation-counts')
|
||||
def update_status(self, service_id, live):
|
||||
return self.update_service(
|
||||
service_id,
|
||||
message_limit=250000 if live else 50,
|
||||
restricted=(not live),
|
||||
)
|
||||
|
||||
# This method is not cached because it calls through to one which is
|
||||
def update_service_with_properties(self, service_id, properties):
|
||||
return self.update_service(service_id, **properties)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
from app.notify_client import NotifyAdminAPIClient
|
||||
from app.notify_client import NotifyAdminAPIClient, cache
|
||||
|
||||
|
||||
class StatusApiClient(NotifyAdminAPIClient):
|
||||
@@ -7,5 +6,9 @@ class StatusApiClient(NotifyAdminAPIClient):
|
||||
def get_status(self, *params):
|
||||
return self.get(url='/_status', *params)
|
||||
|
||||
@cache.set('live-service-and-organisation-counts')
|
||||
def get_count_of_live_services_and_organisations(self):
|
||||
return self.get(url='/_status/live-service-and-organisation-counts')
|
||||
|
||||
|
||||
status_api_client = StatusApiClient()
|
||||
|
||||
Reference in New Issue
Block a user