From 40d8a71bf8219e0a07633d47127da47eabbd296f Mon Sep 17 00:00:00 2001 From: ibuler Date: Thu, 15 Jun 2023 09:37:00 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=20json=20m2m=20filte?= =?UTF-8?q?r?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/common/db/fields.py | 2 +- apps/terminal/connect_methods.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/common/db/fields.py b/apps/common/db/fields.py index 7aa1971d6..bd968c734 100644 --- a/apps/common/db/fields.py +++ b/apps/common/db/fields.py @@ -502,7 +502,7 @@ class JSONManyToManyDescriptor: value = [value.id] value = set(map(str, value)) rule_value = set(map(str, rule_value)) - res &= value.issubset(rule_value) + res &= value & rule_value else: logging.error("unknown match: {}".format(rule['match'])) res &= False diff --git a/apps/terminal/connect_methods.py b/apps/terminal/connect_methods.py index 1ed9e14f1..e38a8d123 100644 --- a/apps/terminal/connect_methods.py +++ b/apps/terminal/connect_methods.py @@ -104,13 +104,15 @@ class NativeClient(TextChoices): xpack_protocols = cls.xpack_protocols() for protocol, _clients in clients_map.items(): + if not settings.XPACK_ENABLED and protocol in xpack_protocols: + continue + if isinstance(_clients, dict): if os == 'all': _clients = list(itertools.chain(*_clients.values())) else: _clients = _clients.get(os, _clients['default']) - if protocol in xpack_protocols: - continue + for client in _clients: if not settings.XPACK_ENABLED and client in cls.xpack_methods(): continue