mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-11 09:28:27 -04:00
Initial front end count steps
This commit is contained in:
committed by
Carlo Costino
parent
63a4a92657
commit
2fbda1cd0c
@@ -287,8 +287,9 @@ def init_app(application):
|
|||||||
remaining_global_messages = 0
|
remaining_global_messages = 0
|
||||||
|
|
||||||
if current_app:
|
if current_app:
|
||||||
|
service_id = session.get("service_id")
|
||||||
global_limit = current_app.config["GLOBAL_SERVICE_MESSAGE_LIMIT"]
|
global_limit = current_app.config["GLOBAL_SERVICE_MESSAGE_LIMIT"]
|
||||||
global_messages_count = service_api_client.get_global_notification_count()
|
global_messages_count = service_api_client.get_global_notification_count(service_id)
|
||||||
remaining_global_messages = global_limit - global_messages_count
|
remaining_global_messages = global_limit - global_messages_count
|
||||||
return {"daily_global_messages_remaining": remaining_global_messages}
|
return {"daily_global_messages_remaining": remaining_global_messages}
|
||||||
|
|
||||||
|
|||||||
@@ -497,11 +497,8 @@ class ServiceAPIClient(NotifyAdminAPIClient):
|
|||||||
|
|
||||||
return int(count)
|
return int(count)
|
||||||
|
|
||||||
def get_global_notification_count(self):
|
def get_global_notification_count(self, service_id):
|
||||||
# if cache is not set, or not enabled, return 0
|
return self.get("/service/{}/notification-count".format(service_id))
|
||||||
count = redis_client.get(daily_total_cache_key()) or 0
|
|
||||||
|
|
||||||
return int(count)
|
|
||||||
|
|
||||||
|
|
||||||
service_api_client = ServiceAPIClient()
|
service_api_client = ServiceAPIClient()
|
||||||
|
|||||||
Reference in New Issue
Block a user