update log messages in delete task.

less prose, clearer output. (hopefully)
This commit is contained in:
Leo Hemsted
2021-12-14 15:24:35 +00:00
parent 0dc0e184b9
commit 228d72dc8f
+12 -10
View File
@@ -89,10 +89,8 @@ def delete_letter_notifications_older_than_retention():
def _delete_notifications_older_than_retention_by_type(notification_type): def _delete_notifications_older_than_retention_by_type(notification_type):
current_app.logger.info(
'Deleting {} notifications for services with flexible data retention'.format(notification_type))
flexible_data_retention = fetch_service_data_retention_for_all_services_by_notification_type(notification_type) flexible_data_retention = fetch_service_data_retention_for_all_services_by_notification_type(notification_type)
for f in flexible_data_retention: for f in flexible_data_retention:
day_to_delete_backwards_from = get_london_midnight_in_utc( day_to_delete_backwards_from = get_london_midnight_in_utc(
convert_utc_to_bst(datetime.utcnow()).date() - timedelta(days=f.days_of_retention) convert_utc_to_bst(datetime.utcnow()).date() - timedelta(days=f.days_of_retention)
@@ -116,11 +114,6 @@ def _delete_notifications_older_than_retention_by_type(notification_type):
service_ids_to_purge = service_ids_that_have_sent_notifications_recently - service_ids_with_data_retention service_ids_to_purge = service_ids_that_have_sent_notifications_recently - service_ids_with_data_retention
current_app.logger.info('Deleting {} notifications for {} services without flexible data retention'.format(
notification_type,
len(service_ids_to_purge)
))
for service_id in service_ids_to_purge: for service_id in service_ids_to_purge:
delete_notifications_for_service_and_type.apply_async(queue=QueueNames.REPORTING, kwargs={ delete_notifications_for_service_and_type.apply_async(queue=QueueNames.REPORTING, kwargs={
'service_id': service_id, 'service_id': service_id,
@@ -128,6 +121,12 @@ def _delete_notifications_older_than_retention_by_type(notification_type):
'datetime_to_delete_before': seven_days_ago 'datetime_to_delete_before': seven_days_ago
}) })
current_app.logger.info(
f'delete-notifications-older-than-retention: triggered subtasks for notification_type {notification_type}: '
f'{len(service_ids_with_data_retention)} services with flexible data retention, '
f'{len(service_ids_to_purge)} services without flexible data retention'
)
@notify_celery.task(name='delete-notifications-for-service-and-type') @notify_celery.task(name='delete-notifications-for-service-and-type')
def delete_notifications_for_service_and_type(service_id, notification_type, datetime_to_delete_before): def delete_notifications_for_service_and_type(service_id, notification_type, datetime_to_delete_before):
@@ -139,8 +138,11 @@ def delete_notifications_for_service_and_type(service_id, notification_type, dat
) )
end = datetime.utcnow() end = datetime.utcnow()
current_app.logger.info( current_app.logger.info(
f'Deleted {num_deleted} {notification_type} notifications for ' f'delete-notifications-for-service-and-type: '
f'service id: {service_id} in {(end - start).seconds} seconds' f'service: {service_id}, '
f'notification_type: {notification_type}, '
f'count deleted: {num_deleted}, '
f'duration: {(end - start).seconds} seconds'
) )