Changes to how we log to avoid unneeded DB calls.

This commit is contained in:
Martyn Inglis
2017-05-05 15:21:13 +01:00
parent 07daa369a3
commit a340ed6f46

View File

@@ -46,6 +46,8 @@ def persist_notification(
notification_id=None,
simulated=False
):
notification_created_at = created_at or datetime.utcnow()
notification = Notification(
id=notification_id,
template_id=template_id,
@@ -57,7 +59,7 @@ def persist_notification(
notification_type=notification_type,
api_key_id=api_key_id,
key_type=key_type,
created_at=created_at or datetime.utcnow(),
created_at=notification_created_at,
job_id=job_id,
job_row_number=job_row_number,
client_reference=client_reference,
@@ -80,7 +82,7 @@ def persist_notification(
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)
"{} {} created at {}".format(notification_type, notification_id, notification_created_at)
)
return notification