Skip to content

Commit

Permalink
feature: 提供 Agent 包管理后台基础接口 (closed #1683)
Browse files Browse the repository at this point in the history
  • Loading branch information
ping15 committed Jan 25, 2024
1 parent 16128a9 commit d636bef
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 13 deletions.
44 changes: 33 additions & 11 deletions apps/node_man/views/package_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="获取快速筛选信息",
Expand Down Expand Up @@ -196,32 +198,52 @@ 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(
[
{
"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()),
},
]
)
Expand Down
4 changes: 2 additions & 2 deletions config/local_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down

0 comments on commit d636bef

Please sign in to comment.