Skip to content

Commit

Permalink
feat(backend): ip 选择器提高查询效率 #8970
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzhw8 committed Jan 8, 2025
1 parent 4928cea commit 854fe85
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .gtmproject.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ github:
repo_name: "blueking-dbm"

# 指定里程碑ID,
milestone_id: "11"
milestone_id: "12"

project:
# 主分支
Expand Down
9 changes: 7 additions & 2 deletions dbm-ui/backend/db_services/ipchooser/handlers/host_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,10 @@ def details(
"""

rules = []
bk_host_ids = []
for host_info in host_list:
if "host_id" in host_info:
rule = {"field": "bk_host_id", "operator": "equal", "value": host_info["host_id"]}
bk_host_ids.append(host_info["host_id"])
else:
rule = {
"condition": "AND",
Expand All @@ -173,6 +174,10 @@ def details(
{"field": "bk_cloud_id", "operator": "equal", "value": host_info["cloud_id"]},
],
}
rules.append(rule)
rules.append(rule)

# 合并为 in 查询,提高查询效率
if bk_host_ids:
rules.append({"field": "bk_host_id", "operator": "in", "value": bk_host_ids})

return cls.details_base(scope_list, {"condition": "OR", "rules": rules}, mode)

0 comments on commit 854fe85

Please sign in to comment.