Ensure we count the tasks as well as the API calls.

After we have written to the database and placed it on a deliver queue we count it in the cache against the service.

This is the equivalent of doing it at the end of the API call.
This commit is contained in:
Martyn Inglis
2016-11-11 17:36:38 +00:00
parent 033a3e530b
commit 4c0c30bb2e
3 changed files with 117 additions and 64 deletions

View File

@@ -28,6 +28,8 @@ from app.models import (
)
from app.service.utils import service_allowed_to_send_to
from app.statsd_decorators import statsd
from app import redis_store
from app.clients.redis import cache_key
@notify_celery.task(name="process-job")
@@ -148,6 +150,8 @@ def send_sms(self,
"RETRY FAILED: task send_sms failed for notification {}".format(notification.id),
e
)
else:
redis_store.inc(cache_key(service_id))
@notify_celery.task(bind=True, name="send-email", max_retries=5, default_retry_delay=300)
@@ -187,3 +191,5 @@ def send_email(self, service_id,
"RETRY FAILED: task send_email failed for notification {}".format(notification.id),
e
)
else:
redis_store.inc(cache_key(service_id))