From d636befba9ab7de6092843de9a71aec36df779ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E7=A7=8B=E5=B9=B3?= <446105468@qq.com> Date: Thu, 25 Jan 2024 11:33:45 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20=20=E6=8F=90=E4=BE=9B=20Agent=20?= =?UTF-8?q?=E5=8C=85=E7=AE=A1=E7=90=86=E5=90=8E=E5=8F=B0=E5=9F=BA=E7=A1=80?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=20(closed=20#1683)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/node_man/views/package_manage.py | 44 ++++++++++++++++++++------- config/local_settings.py | 4 +-- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/apps/node_man/views/package_manage.py b/apps/node_man/views/package_manage.py index 5e2075df6..40b0d9dfb 100644 --- a/apps/node_man/views/package_manage.py +++ b/apps/node_man/views/package_manage.py @@ -167,7 +167,9 @@ def update(self, request, validated_data, *args, **kwargs): tags=PACKAGE_MANAGE_VIEW_TAGS, ) def destroy(self, request, *args, **kwargs): - return super(PackageManageViewSet, self).destroy(request, *args, **kwargs) + # todo: 前端需求,等联调完改回来 + super(PackageManageViewSet, self).destroy(request, *args, **kwargs) + return Response(data=[]) @swagger_auto_schema( operation_summary="获取快速筛选信息", @@ -196,12 +198,22 @@ def quick_search_condition(self, request, *args, **kwargs): """ gse_packages = self.filter_queryset(self.get_queryset()).values("version", "os", "cpu_arch", "version_log") - version_count_map: Dict[str, int] = defaultdict(int) - os_cpu_arch_count_map: Dict[str, int] = defaultdict(int) + version__count_map: Dict[str, int] = defaultdict(int) + os_cpu_arch__count_map: Dict[str, int] = defaultdict(int) + version__version_log_map: Dict[str, str] = defaultdict(str) + os_cpu_arch__version_log_map: Dict[str, str] = defaultdict(str) for package in gse_packages: - version_count_map[package["version"]] += 1 - os_cpu_arch_count_map[f"{package['os']}_{package['cpu_arch']}"] += 1 + version, os_cpu_arch = package["version"], f"{package['os']}_{package['cpu_arch']}" + + version__count_map[version] += 1 + os_cpu_arch__count_map[os_cpu_arch] += 1 + + if version not in version__version_log_map: + version__version_log_map[version] = package["version_log"] + + if os_cpu_arch not in os_cpu_arch__version_log_map: + os_cpu_arch__version_log_map[os_cpu_arch] = package["version_log"] return Response( [ @@ -209,19 +221,29 @@ def quick_search_condition(self, request, *args, **kwargs): "name": _("操作系统/架构"), "id": "os_cpu_arch", "children": [ - {"id": key, "name": key.capitalize(), "count": value} - for key, value in os_cpu_arch_count_map.items() + { + "id": os_cpu_arch, + "name": os_cpu_arch.capitalize(), + "count": count, + "description": os_cpu_arch__version_log_map[os_cpu_arch], + } + for os_cpu_arch, count in os_cpu_arch__count_map.items() ], - "count": sum(os_cpu_arch_count_map.values()), + "count": sum(os_cpu_arch__count_map.values()), }, { "name": _("版本号"), "id": "version", "children": [ - {"id": key, "name": key.capitalize(), "count": value} - for key, value in version_count_map.items() + { + "id": version, + "name": version.capitalize(), + "count": count, + "description": version__version_log_map[version], + } + for version, count in version__count_map.items() ], - "count": sum(version_count_map.values()), + "count": sum(version__count_map.values()), }, ] ) diff --git a/config/local_settings.py b/config/local_settings.py index 6113e26b7..15053a543 100644 --- a/config/local_settings.py +++ b/config/local_settings.py @@ -21,9 +21,9 @@ DATABASES = { "default": { "ENGINE": "django.db.backends.mysql", - "NAME": "bk-nodeman-test5", + "NAME": "bk-nodeman-test", "USER": "root", - "PASSWORD": "root", + "PASSWORD": "", "HOST": "127.0.0.1", "PORT": "3306", "OPTIONS": {"charset": "utf8mb4"},