Skip to content

Commit ae0a746

Browse files
committed
feat: modify run last month unified cost parameter by scheduler
Signed-off-by: ImMin5 <[email protected]>
1 parent 9f0676a commit ae0a746

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/spaceone/cost_analysis/service/unified_cost_service.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ def run_unified_cost_by_scheduler(self, params: dict) -> None:
5454
config_mgr = ConfigManager()
5555

5656
current_hour = params["current_hour"]
57-
current_month = datetime.utcnow().strftime("%Y-%m")
57+
current_date = datetime.utcnow()
58+
current_month = current_date.strftime("%Y-%m")
5859

5960
identity_mgr = IdentityManager()
6061
domain_ids = identity_mgr.list_enabled_domain_ids()
@@ -70,7 +71,10 @@ def run_unified_cost_by_scheduler(self, params: dict) -> None:
7071
if self._check_unified_cost_job_is_confirmed_with_month(
7172
domain_id, current_month
7273
):
73-
self.run_last_month_unified_costs(domain_id, current_month)
74+
last_month = (current_date - relativedelta(months=1)).strftime(
75+
"%Y-%m"
76+
)
77+
self.run_last_month_unified_costs(domain_id, last_month)
7478

7579
except Exception as e:
7680
_LOGGER.error(

0 commit comments

Comments
 (0)