Skip to content

Commit

Permalink
fix(backend): 修复cc过滤缓慢的问题 #3967
Browse files Browse the repository at this point in the history
  • Loading branch information
iSecloud authored and zhangzhw8 committed Apr 12, 2024
1 parent f672ace commit bbd1dc3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
23 changes: 12 additions & 11 deletions dbm-ui/backend/db_services/ipchooser/handlers/host_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ def check(
ip = ip_or_cloud_ip.split(constants.CommonEnum.SEP.value)[block_num - 1]
cloud_inner_ip_set.add(f"{host_filter_cloud_id}{constants.CommonEnum.SEP.value}{ip}")

# 尝试将关键字解析为主机 ID,否则就认为是主机名
for key in key_list:
# 尝试将关键字解析为主机 ID,否则就认为是主机名
try:
bk_host_id_set.add(int(key))
except ValueError:
Expand All @@ -133,16 +133,17 @@ def check(
)

# 构建主机过滤器
host_property_filter = {
"condition": "OR",
"rules": [
{"field": "bk_host_id", "operator": "in", "value": list(bk_host_id_set)},
{"field": "bk_host_innerip", "operator": "in", "value": list(inner_ip_set)},
{"field": "bk_host_innerip_v6", "operator": "in", "value": ipv6_list},
{"field": "bk_host_name", "operator": "in", "value": list(bk_host_name_set)},
]
+ cloud_ip_rules,
}
host_filter_rules: typing.List[typing.Dict] = []
if bk_host_name_set:
host_filter_rules.append({"field": "bk_host_name", "operator": "in", "value": list(bk_host_name_set)})
if bk_host_id_set:
host_filter_rules.append({"field": "bk_host_id", "operator": "in", "value": list(bk_host_id_set)})
if inner_ip_set:
host_filter_rules.append({"field": "bk_host_innerip", "operator": "in", "value": list(inner_ip_set)})
if ipv6_list:
host_filter_rules.append({"field": "bk_host_innerip_v6", "operator": "in", "value": ipv6_list})

host_property_filter = {"condition": "OR", "rules": host_filter_rules + cloud_ip_rules}
return cls.details_base(scope_list, host_property_filter, mode)

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion dbm-ui/backend/ticket/models/ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class Meta:

@property
def url(self):
return f"{env.BK_SAAS_HOST}/{self.bk_biz_id}/my-tickets?id={self.id}"
return f"{env.BK_SAAS_HOST}/{self.bk_biz_id}/ticket-manage/index?id={self.id}"

def set_terminated(self):
self.status = TicketStatus.TERMINATED
Expand Down

0 comments on commit bbd1dc3

Please sign in to comment.