From 854fe854457087da75f1cfdd9e2b12b5a057c6fd Mon Sep 17 00:00:00 2001 From: durant <826035498@qq.com> Date: Wed, 8 Jan 2025 17:36:00 +0800 Subject: [PATCH] =?UTF-8?q?feat(backend):=20ip=20=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E5=99=A8=E6=8F=90=E9=AB=98=E6=9F=A5=E8=AF=A2=E6=95=88=E7=8E=87?= =?UTF-8?q?=20#8970?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gtmproject.yaml | 2 +- .../db_services/ipchooser/handlers/host_handler.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.gtmproject.yaml b/.gtmproject.yaml index ea3a6177fd..c8dc38408d 100644 --- a/.gtmproject.yaml +++ b/.gtmproject.yaml @@ -6,7 +6,7 @@ github: repo_name: "blueking-dbm" # 指定里程碑ID, - milestone_id: "11" + milestone_id: "12" project: # 主分支 diff --git a/dbm-ui/backend/db_services/ipchooser/handlers/host_handler.py b/dbm-ui/backend/db_services/ipchooser/handlers/host_handler.py index 6b968ad43d..5d69e3ebf6 100644 --- a/dbm-ui/backend/db_services/ipchooser/handlers/host_handler.py +++ b/dbm-ui/backend/db_services/ipchooser/handlers/host_handler.py @@ -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", @@ -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)