From cec44f60e33770906c466892c99b91b004cf6de2 Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Wed, 11 Dec 2019 13:22:28 +0000 Subject: [PATCH] fix log line typo log lines didn't make sense because the arguments were the wrong way round. As an experiment to try and clean up some of our code a bit, this commit adds f-strings. f-strings were added in python 3.6, as a way to clean up, simplify, and improve the performance of `str.format`. --- app/celery/reporting_tasks.py | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/app/celery/reporting_tasks.py b/app/celery/reporting_tasks.py index 72ac2fd97..7ce1ff57a 100644 --- a/app/celery/reporting_tasks.py +++ b/app/celery/reporting_tasks.py @@ -48,19 +48,13 @@ def create_nightly_billing_for_day(process_day): transit_data = fetch_billing_data_for_day(process_day=process_day) end = datetime.utcnow() - current_app.logger.info('create-nightly-billing-for-day {} fetched in {} seconds'.format( - process_day, - (end - start).seconds) - ) + current_app.logger.info(f'create-nightly-billing-for-day {process_day} fetched in {(end - start).seconds} seconds') for data in transit_data: update_fact_billing(data, process_day) current_app.logger.info( - "create-nightly-billing-for-day task complete. {} rows updated for day: {}".format( - len(transit_data), - process_day - ) + f"create-nightly-billing-for-day task complete. {len(transit_data)} rows updated for day: {process_day}" ) @@ -95,16 +89,14 @@ def create_nightly_notification_status_for_day(process_day, notification_type): start = datetime.utcnow() transit_data = fetch_notification_status_for_day(process_day=process_day, notification_type=notification_type) end = datetime.utcnow() - current_app.logger.info('create-nightly-notification-status-for-day {} type {} fetched in {} seconds'.format( - process_day, - notification_type, - (end - start).seconds) + current_app.logger.info( + f'create-nightly-notification-status-for-day {process_day} type {notification_type} task: ' + f'data fetched in {(end - start).seconds} seconds' ) update_fact_notification_status(transit_data, process_day, notification_type) current_app.logger.info( - "create-nightly-notification-status-for-day task complete: {} rows updated for type {} for day: {}".format( - len(transit_data), process_day, notification_type - ) + f'create-nightly-notification-status-for-day {process_day} type {notification_type} task: ' + f'task complete - {len(transit_data)} rows updated' )