Skip to content

Commit

Permalink
Merge pull request #104 from stat-kwon/master
Browse files Browse the repository at this point in the history
Modify logic of options expressions in data_source_manager
  • Loading branch information
stat-kwon authored Nov 5, 2024
2 parents 8f6dc2f + f328319 commit c6d3c12
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -330,46 +330,6 @@ def _make_query(
end: str,
vars: dict = None,
):

if vars:
self.filter = self.filter or []
for key, value in vars.items():
if key in ["workspace_id", "project_id", "service_account_id"]:
if isinstance(value, list):
self.filter.append(
{"key": key, "value": value, "operator": "in"}
)
else:
self.filter.append(
{"key": key, "value": value, "operator": "eq"}
)
elif key == "region_code":
if isinstance(value, list):
if self.source_type == "COST":
self.filter.append(
{"key": "region_code", "value": value, "operator": "in"}
)
else:
self.filter.append(
{
"key": "labels.Region",
"value": value,
"operator": "in",
}
)
else:
if self.source_type == "COST":
self.filter.append(
{"key": "region_code", "value": value, "operator": "eq"}
)
else:
self.filter.append(
{
"key": "labels.Region",
"value": value,
"operator": "eq",
}
)
if self.filter:
for filter_info in self.filter:
query_value = filter_info.get("v") or filter_info.get("value")
Expand Down
6 changes: 6 additions & 0 deletions src/spaceone/dashboard/service/public_data_table_service.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import copy
from typing import Union

from spaceone.core.service import *
Expand Down Expand Up @@ -250,6 +251,8 @@ def update(
vars = params_dict.get("vars")

if options := params_dict.get("options"):
raw_filter = copy.deepcopy(options.get("filter"))

if pub_data_table_vo.data_type == "ADDED":
ds_mgr = DataSourceManager(
"PUBLIC",
Expand Down Expand Up @@ -308,6 +311,9 @@ def update(
operator: operator_options,
}

if raw_filter:
params_dict["options"]["filter"] = raw_filter

pub_data_table_vo = self.pub_data_table_mgr.update_public_data_table_by_vo(
params_dict, pub_data_table_vo
)
Expand Down

0 comments on commit c6d3c12

Please sign in to comment.