This commit is contained in:
Kenneth Kehl
2025-01-29 07:50:23 -08:00
parent 0381768e58
commit 91585a8b9e
4 changed files with 9 additions and 13 deletions

View File

@@ -179,7 +179,7 @@ def __total_sending_limits_for_job_exceeded(service, job, job_id):
dao_update_job(job) dao_update_job(job)
current_app.logger.exception( current_app.logger.exception(
"Job {} size {} error. Total sending limits {} exceeded".format( "Job {} size {} error. Total sending limits {} exceeded".format(
job_id, job.notification_count, service.message_limit job_id, job.notification_count, service.total_message_limit
), ),
) )
return True return True

View File

@@ -136,11 +136,15 @@ def send_sms_to_provider(notification):
msg = f"Send to AWS!!! for job_id {n.job_id} row_number {n.job_row_number} message_id {message_id}" msg = f"Send to AWS!!! for job_id {n.job_id} row_number {n.job_row_number} message_id {message_id}"
current_app.logger.info(hilite(msg)) current_app.logger.info(hilite(msg))
notification.billable_units = template.fragment_count notification.billable_units = template.fragment_count
current_app.logger.info("GOING TO UPDATE NOTI TO SENDING")
update_notification_to_sending(notification, provider) update_notification_to_sending(notification, provider)
cache_key = total_limit_cache_key(service.id) cache_key = total_limit_cache_key(service.id)
redis_store.incr(cache_key) redis_store.incr(cache_key)
current_app.logger.info(
hilite(
f"message count for service {n.service_id} now {redis_store.get(cache_key)}"
)
)
return message_id return message_id

View File

@@ -14,7 +14,7 @@ from app.models import ServicePermission
from app.notifications.process_notifications import create_content_for_notification from app.notifications.process_notifications import create_content_for_notification
from app.serialised_models import SerialisedTemplate from app.serialised_models import SerialisedTemplate
from app.service.utils import service_allowed_to_send_to from app.service.utils import service_allowed_to_send_to
from app.utils import get_public_notify_type_text, hilite from app.utils import get_public_notify_type_text
from notifications_utils import SMS_CHAR_COUNT_LIMIT from notifications_utils import SMS_CHAR_COUNT_LIMIT
from notifications_utils.clients.redis import total_limit_cache_key from notifications_utils.clients.redis import total_limit_cache_key
from notifications_utils.recipients import ( from notifications_utils.recipients import (
@@ -46,21 +46,13 @@ def check_service_over_total_message_limit(key_type, service):
service_stats = 0 service_stats = 0
redis_store.set(cache_key, service_stats, ex=seconds_difference) redis_store.set(cache_key, service_stats, ex=seconds_difference)
return service_stats return service_stats
# TODO CHANGE THIS BACK TO SERVICE TOTAL MESSAGE LIMIT if int(service_stats) >= service.total_message_limit:
if int(service_stats) >= 5:
# if int(service_stats) >= service.total_message_limit:
current_app.logger.warning( current_app.logger.warning(
"service {} has been rate limited for total use sent {} limit {}".format( "service {} has been rate limited for total use sent {} limit {}".format(
service.id, int(service_stats), service.total_message_limit service.id, int(service_stats), service.total_message_limit
) )
) )
raise TotalRequestsError(service.total_message_limit) raise TotalRequestsError(service.total_message_limit)
else:
print(
hilite(
f"TOTAL MESSAGE LIMIT {service.total_message_limit} CURRENT {service_stats}"
)
)
return int(service_stats) return int(service_stats)

View File

@@ -1140,7 +1140,7 @@ def get_service_message_ratio():
return { return {
"messages_sent": messages_sent, "messages_sent": messages_sent,
"total_message_limit": my_service.total_message_limit, "total_message_limit": my_service.total_message_limit,
} }, 200
@service_blueprint.route("/monthly-data-by-service") @service_blueprint.route("/monthly-data-by-service")