Increment the redis cache on a successful API call.

These means that the cache count is on Notifications in the database NOT notifications sent to providers. If the provider fails to accept the notification, it still counts.

I think this is correct, as they have done the work to send it so we should count it, though there is an argument that we should count them on sending?
This commit is contained in:
Martyn Inglis
2016-11-11 17:19:27 +00:00
parent 88f04a46cf
commit 033a3e530b
3 changed files with 111 additions and 3 deletions

View File

@@ -37,6 +37,7 @@ from app.schemas import (
from app.service.utils import service_allowed_to_send_to
from app.utils import pagination_links
from app import redis_store
from app.clients import redis
notifications = Blueprint('notifications', __name__)
@@ -245,7 +246,7 @@ def send_notification(notification_type):
notification_id = create_uuid() if saved_notification is None else saved_notification.id
notification.update({"template_version": template.version})
redis_store.inc(redis.cache_key(service.id))
return jsonify(
data=get_notification_return_data(
notification_id,

View File

@@ -15,8 +15,6 @@ def check_service_message_limit(key_type, service):
if not service_stats:
service_stats = services_dao.fetch_todays_total_message_count(service.id)
redis_store.set(cache_key, service_stats, ex=3600)
print(service_stats)
print(service.message_limit)
if service_stats >= service.message_limit:
raise TooManyRequestsError(service.message_limit)