From bcb304fd2b9aa8a656465668cf631de9975871fe Mon Sep 17 00:00:00 2001 From: Cody Myers Date: Fri, 24 Jun 2022 09:09:13 -0400 Subject: [PATCH] COST-2715: Include report_period_id in tag based rates delete. (#3702) Co-authored-by: Andrew Berglund --- koku/masu/processor/ocp/ocp_cost_model_cost_updater.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/koku/masu/processor/ocp/ocp_cost_model_cost_updater.py b/koku/masu/processor/ocp/ocp_cost_model_cost_updater.py index 6421ccdd35..3c1332d3e5 100644 --- a/koku/masu/processor/ocp/ocp_cost_model_cost_updater.py +++ b/koku/masu/processor/ocp/ocp_cost_model_cost_updater.py @@ -339,12 +339,15 @@ def _delete_tag_usage_costs(self, start_date, end_date, source_uuid): """Delete existing tag based rated entries""" # Delete existing records with OCPReportDBAccessor(self._schema) as report_accessor: + with schema_context(self._schema): + report_period = report_accessor.report_periods_for_provider_uuid(self._provider.uuid, start_date) + report_period_id = report_period.id report_accessor.delete_line_item_daily_summary_entries_for_date_range_raw( source_uuid, start_date, end_date, table=OCPUsageLineItemDailySummary, - filters={"monthly_cost_type": "Tag"}, + filters={"monthly_cost_type": "Tag", "report_period_id": report_period_id}, ) def update_summary_cost_model_costs(self, start_date, end_date):