To check the daily limit get the daily notification_count from redis.

The daily limit cache is set by the api when a notification is created. There is one cache key per service per day and it expires after 24 hours.
This commit is contained in:
Rebecca Law
2021-06-23 15:56:05 +01:00
parent 7930a53a58
commit 44f02f2e30
4 changed files with 17 additions and 25 deletions

View File

@@ -612,8 +612,8 @@ def _check_messages(service_id, template_id, upload_id, preview_row, letters_as_
if e.status_code != 404:
raise
statistics = service_api_client.get_service_statistics(service_id, today_only=True)
remaining_messages = (current_service.message_limit - sum(stat['requested'] for stat in statistics.values()))
notification_count = service_api_client.get_notification_count(service_id)
remaining_messages = (current_service.message_limit - notification_count)
contents = s3download(service_id, upload_id)