mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-21 07:51:13 -05:00
Remove the delete query when updating the ft_billing. It's in the wrong place and we also should not need it.
This commit is contained in:
@@ -159,7 +159,7 @@ def fetch_billing_data_for_day(process_day, service_id=None):
|
|||||||
notification_type=notification_type,
|
notification_type=notification_type,
|
||||||
start_date=start_date,
|
start_date=start_date,
|
||||||
end_date=end_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 data has been purged from Notification then use NotificationHistory
|
||||||
if len(results) == 0:
|
if len(results) == 0:
|
||||||
@@ -285,10 +285,6 @@ def update_fact_billing(data, process_day):
|
|||||||
data.postage)
|
data.postage)
|
||||||
billing_record = create_billing_record(data, rate, process_day)
|
billing_record = create_billing_record(data, rate, process_day)
|
||||||
|
|
||||||
FactBilling.query.filter(
|
|
||||||
FactBilling.bst_date == process_day
|
|
||||||
).delete()
|
|
||||||
|
|
||||||
table = FactBilling.__table__
|
table = FactBilling.__table__
|
||||||
'''
|
'''
|
||||||
This uses the Postgres upsert to avoid race conditions when two threads try to insert
|
This uses the Postgres upsert to avoid race conditions when two threads try to insert
|
||||||
|
|||||||
@@ -38,13 +38,22 @@ def fetch_notification_status_for_day(process_day):
|
|||||||
# if no rows try notificationHistory
|
# if no rows try notificationHistory
|
||||||
for service_id in service_ids:
|
for service_id in service_ids:
|
||||||
for notification_type in [EMAIL_TYPE, SMS_TYPE, LETTER_TYPE]:
|
for notification_type in [EMAIL_TYPE, SMS_TYPE, LETTER_TYPE]:
|
||||||
table = Notification
|
data_for_service_and_type = query_for_fact_status_data(
|
||||||
data_for_service_and_type = query_for_fact_status_data(table, start_date, end_date, notification_type, service_id)
|
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:
|
if len(data_for_service_and_type) == 0:
|
||||||
table = NotificationHistory
|
data_for_service_and_type = query_for_fact_status_data(
|
||||||
data_for_service_and_type = query_for_fact_status_data(table, start_date, end_date, notification_type, service_id)
|
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
|
all_data_for_process_day = all_data_for_process_day + data_for_service_and_type
|
||||||
|
|
||||||
return all_data_for_process_day
|
return all_data_for_process_day
|
||||||
|
|||||||
Reference in New Issue
Block a user