Add notif count and history count together

This commit is contained in:
Andrew Shumway
2023-10-17 11:11:17 -06:00
committed by Carlo Costino
parent 2fbda1cd0c
commit 81f4b1436d
2 changed files with 6 additions and 5 deletions

View File

@@ -285,12 +285,13 @@ def init_app(application):
@application.context_processor
def _attach_current_global_daily_messages():
remaining_global_messages = 0
if current_app:
service_id = session.get("service_id")
global_limit = current_app.config["GLOBAL_SERVICE_MESSAGE_LIMIT"]
global_messages_count = service_api_client.get_global_notification_count(service_id)
remaining_global_messages = global_limit - global_messages_count
if service_id:
global_limit = current_app.config["GLOBAL_SERVICE_MESSAGE_LIMIT"]
global_messages_count = service_api_client.get_global_notification_count(service_id)
remaining_global_messages = global_limit - global_messages_count.get("count")
return {"daily_global_messages_remaining": remaining_global_messages}
@application.before_request

View File

@@ -498,7 +498,7 @@ class ServiceAPIClient(NotifyAdminAPIClient):
return int(count)
def get_global_notification_count(self, service_id):
return self.get("/service/{}/notification-count".format(service_id))
return self.get("/service/{}/notification-count".format(service_id))
service_api_client = ServiceAPIClient()