perf: app tree 添加attrs,luna 使用

This commit is contained in:
ibuler
2022-03-28 17:06:06 +08:00
committed by 老广
parent e303b4f571
commit a20de3df16
2 changed files with 14 additions and 3 deletions

View File

@@ -48,20 +48,24 @@ class SerializeApplicationToTreeNodeMixin:
root_node = self.create_root_node()
tree_nodes.append(root_node)
organizations = self.filter_organizations(applications)
for i, org in enumerate(organizations):
tree_id = urlencode({'org_id': str(org.id)})
apps = applications.filter(org_id=org.id)
# 组织节点
org_node = org.as_tree_node(oid=tree_id, pid=root_node.id)
org_node.name += '({})'.format(apps.count())
tree_nodes.append(org_node)
# 类别节点
category_type_nodes = Application.create_category_type_tree_nodes(
apps, tree_id, show_empty=False
)
tree_nodes += category_type_nodes
for app in apps:
app_node = app.as_tree_node(tree_id, is_luna=True)
app_node = app.as_tree_node(tree_id, k8s_as_tree=True)
tree_nodes.append(app_node)
return tree_nodes