Skip to content

Commit

Permalink
Merge pull request #276 from ImMin5/master
Browse files Browse the repository at this point in the history
Fix report month error when run CostReportConfig
  • Loading branch information
ImMin5 committed Sep 6, 2024
2 parents 489871c + fe9d151 commit 76684f2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/spaceone/cost_analysis/manager/cost_report_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ def get_cost_report(

return self.cost_report_model.get(**conditions)

@staticmethod
def delete_cost_report_by_vo(cost_report_vo: CostReport) -> None:
cost_report_vo.delete()

def filter_cost_reports(self, **conditions) -> QuerySet:
return self.cost_report_model.filter(**conditions)

Expand Down
7 changes: 5 additions & 2 deletions src/spaceone/cost_analysis/service/cost_report_serivce.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ def _delete_old_cost_reports(
)

cost_report_data_vos.delete()
cost_report_vo.delete()
self.cost_report_mgr.delete_cost_report_by_vo(cost_report_vo)

_LOGGER.debug(
f"[_delete_last_month_cost_reports] delete cost reports ({cost_report_config_id}:{report_month}) (count = {total_count}))"
Expand Down Expand Up @@ -725,7 +725,7 @@ def _get_is_create_report_and_report_month(
report_date = current_date - relativedelta(months=1)

if (
current_date < report_date
current_date > report_date
and retry_date <= issue_date.replace(day=issue_day) <= current_date
):
is_create_report = True
Expand All @@ -741,6 +741,9 @@ def _get_is_create_report_and_report_month(
is_create_report = True
report_month = (current_date - relativedelta(months=1)).strftime("%Y-%m")

_LOGGER.debug(
f"[get_is_create_report_and_report_month] cost_report_config_id: {cost_report_config_id} is_create_report: {is_create_report}, report_month: {report_month}"
)
return is_create_report, report_month

def _check_success_cost_report_exist(
Expand Down

0 comments on commit 76684f2

Please sign in to comment.