fix total message limit so it works

This commit is contained in:
Kenneth Kehl
2025-01-23 13:28:26 -08:00
parent 7e913983a4
commit 0d874828e4
5 changed files with 27 additions and 25 deletions

View File

@@ -14,6 +14,7 @@ from app.dao.notifications_dao import update_notification_status_by_id
from app.delivery import send_to_providers
from app.enums import NotificationStatus
from app.exceptions import NotificationTechnicalFailureException
from notifications_utils.clients.redis import total_limit_cache_key
@notify_celery.task(
@@ -41,6 +42,9 @@ def deliver_sms(self, notification_id):
# Code branches off to send_to_providers.py
send_to_providers.send_sms_to_provider(notification)
cache_key = total_limit_cache_key(notification.service_id)
redis_store.incr(cache_key)
except Exception as e:
update_notification_status_by_id(
notification_id,

View File

@@ -166,7 +166,7 @@ def process_row(row, template, job, service, sender_id=None):
# Assuming the limit is annual, is it calendar year, fiscal year, MOU year?
# Do we need a command to run to clear the redis value, or should it happen automatically?
def __total_sending_limits_for_job_exceeded(service, job, job_id):
print(hilite("ENTER __total_sending_limits_for_job_exceeded"))
try:
total_sent = check_service_over_total_message_limit(KeyType.NORMAL, service)
if total_sent + job.notification_count > service.total_message_limit: