diff --git a/app/dao/fact_billing_dao.py b/app/dao/fact_billing_dao.py index 92e27189e..b27ac7ea1 100644 --- a/app/dao/fact_billing_dao.py +++ b/app/dao/fact_billing_dao.py @@ -159,7 +159,7 @@ def fetch_billing_data_for_day(process_day, service_id=None): notification_type=notification_type, start_date=start_date, end_date=end_date, - service_id = id_of_service + service_id=id_of_service ) # If data has been purged from Notification then use NotificationHistory if len(results) == 0: @@ -285,10 +285,6 @@ def update_fact_billing(data, process_day): data.postage) billing_record = create_billing_record(data, rate, process_day) - FactBilling.query.filter( - FactBilling.bst_date == process_day - ).delete() - table = FactBilling.__table__ ''' This uses the Postgres upsert to avoid race conditions when two threads try to insert diff --git a/app/dao/fact_notification_status_dao.py b/app/dao/fact_notification_status_dao.py index 1b9164b73..2836e62df 100644 --- a/app/dao/fact_notification_status_dao.py +++ b/app/dao/fact_notification_status_dao.py @@ -38,13 +38,22 @@ def fetch_notification_status_for_day(process_day): # if no rows try notificationHistory for service_id in service_ids: for notification_type in [EMAIL_TYPE, SMS_TYPE, LETTER_TYPE]: - table = Notification - data_for_service_and_type = query_for_fact_status_data(table, start_date, end_date, notification_type, service_id) + data_for_service_and_type = query_for_fact_status_data( + table=Notification, + start_date=start_date, + end_date=end_date, + notification_type=notification_type, + service_id=service_id + ) if len(data_for_service_and_type) == 0: - table = NotificationHistory - data_for_service_and_type = query_for_fact_status_data(table, start_date, end_date, notification_type, service_id) - + data_for_service_and_type = query_for_fact_status_data( + table=NotificationHistory, + start_date=start_date, + end_date=end_date, + notification_type=notification_type, + service_id=service_id + ) all_data_for_process_day = all_data_for_process_day + data_for_service_and_type return all_data_for_process_day