Skip to content

Commit 20c3977

Browse files
authored
Merge pull request #297 from whdalsrnt/master
refactor: apply hint for performance
2 parents 3c05436 + b6ac46c commit 20c3977

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

src/spaceone/cost_analysis/service/job_service.py

+7-13
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,6 @@ def get_cost_data(self, params):
319319
job_id,
320320
data_source_id,
321321
domain_id,
322-
data_source_vo.cost_data_keys,
323-
data_source_vo.cost_additional_info_keys,
324-
data_source_vo.cost_tag_keys,
325322
job_task_vo.workspace_id,
326323
)
327324

@@ -628,9 +625,6 @@ def _close_job(
628625
job_id: str,
629626
data_source_id: str,
630627
domain_id: str,
631-
data_keys: list,
632-
additional_info_keys: list,
633-
tag_keys: list,
634628
workspace_id: str = None,
635629
) -> None:
636630
job_vo: Job = self.job_mgr.get_job(job_id, domain_id, workspace_id)
@@ -639,10 +633,6 @@ def _close_job(
639633
if job_vo.remained_tasks == 0:
640634
if job_vo.status == "IN_PROGRESS":
641635
try:
642-
# self._aggregate_cost_data(
643-
# job_vo, data_keys, additional_info_keys, tag_keys
644-
# )
645-
646636
for changed_vo in job_vo.changed:
647637
self._delete_changed_cost_data(
648638
job_vo,
@@ -765,7 +755,8 @@ def _delete_old_cost_data(self, data_source_id: str, domain_id: str):
765755
{"k": "billed_month", "v": old_billed_month, "o": "lt"},
766756
{"k": "data_source_id", "v": data_source_id, "o": "eq"},
767757
{"k": "domain_id", "v": domain_id, "o": "eq"},
768-
]
758+
],
759+
"hint": "COMPOUND_INDEX_FOR_SYNC_JOB_2",
769760
}
770761

771762
cost_vos, total_count = self.cost_mgr.list_costs(
@@ -779,7 +770,8 @@ def _delete_old_cost_data(self, data_source_id: str, domain_id: str):
779770
{"k": "billed_year", "v": old_billed_year, "o": "lt"},
780771
{"k": "data_source_id", "v": data_source_id, "o": "eq"},
781772
{"k": "domain_id", "v": domain_id, "o": "eq"},
782-
]
773+
],
774+
"hint": "COMPOUND_INDEX_FOR_SEARCH_2",
783775
}
784776

785777
monthly_cost_vos, total_count = self.cost_mgr.list_monthly_costs(
@@ -799,7 +791,8 @@ def _delete_changed_cost_data(
799791
{"k": "data_source_id", "v": job_vo.data_source_id, "o": "eq"},
800792
{"k": "domain_id", "v": job_vo.domain_id, "o": "eq"},
801793
{"k": "job_id", "v": job_vo.job_id, "o": "not"},
802-
]
794+
],
795+
"hint": "COMPOUND_INDEX_FOR_SYNC_JOB_2",
803796
}
804797

805798
if end:
@@ -818,6 +811,7 @@ def _delete_changed_cost_data(
818811
f"[_delete_changed_cost_data] delete costs (count = {total_count})"
819812
)
820813

814+
query["hint"] = "COMPOUND_INDEX_FOR_SYNC_JOB"
821815
monthly_cost_vos, total_count = self.cost_mgr.list_monthly_costs(
822816
copy.deepcopy(query), domain_id
823817
)

0 commit comments

Comments
 (0)