Fix bug where the increment calls set count to 1 if the cache does not exist.

This commit is contained in:
Rebecca Law
2017-02-15 11:49:19 +00:00
parent 01dcb52389
commit 74e29708f9
2 changed files with 32 additions and 9 deletions

View File

@@ -62,8 +62,10 @@ def persist_notification(template_id,
)
if not simulated:
dao_create_notification(notification)
redis_store.incr(redis.daily_limit_cache_key(service.id))
redis_store.increment_hash_value(cache_key_for_service_template_counter(service.id), template_id)
if redis_store.get(redis.daily_limit_cache_key(service.id)):
redis_store.incr(redis.daily_limit_cache_key(service.id))
if redis_store.get_all_from_hash(cache_key_for_service_template_counter(service.id)):
redis_store.increment_hash_value(cache_key_for_service_template_counter(service.id), template_id)
current_app.logger.info(
"{} {} created at {}".format(notification.notification_type, notification.id, notification.created_at)
)