From 246016a894c39ce99275664b4d4e7e8d5e548519 Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Tue, 14 Dec 2021 16:20:50 +0000 Subject: [PATCH] don't log if we dont delete anything for a service we try and delete for lots of services. this includes services that don't actually have anything to delete that day. that might be because they had a custom data retention so we always go to check them, or because they only sent test notifications (which we'll delete but not include in the count in the log line). we don't really need to see log lines saying that we didn't delete anything for that service - that's just a long list of boring log messages that will hide the actual interesting stuff - which services we did delete content for. --- app/celery/nightly_tasks.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/celery/nightly_tasks.py b/app/celery/nightly_tasks.py index 0da5ccc66..04b3fc31a 100644 --- a/app/celery/nightly_tasks.py +++ b/app/celery/nightly_tasks.py @@ -136,14 +136,15 @@ def delete_notifications_for_service_and_type(service_id, notification_type, dat service_id, datetime_to_delete_before, ) - end = datetime.utcnow() - current_app.logger.info( - f'delete-notifications-for-service-and-type: ' - f'service: {service_id}, ' - f'notification_type: {notification_type}, ' - f'count deleted: {num_deleted}, ' - f'duration: {(end - start).seconds} seconds' - ) + if num_deleted: + end = datetime.utcnow() + current_app.logger.info( + f'delete-notifications-for-service-and-type: ' + f'service: {service_id}, ' + f'notification_type: {notification_type}, ' + f'count deleted: {num_deleted}, ' + f'duration: {(end - start).seconds} seconds' + ) @notify_celery.task(name='timeout-sending-notifications')