mirror of https://github.com/jumpserver/jumpserver
Merge pull request #10825 from jumpserver/pr@dev@perf_asset_node
perf: 接口sql优化 /api/v1/assets/nodes/children/tree/pull/10829/head^2
commit
7950718582
|
@ -127,10 +127,13 @@ class NodeChildrenAsTreeApi(SerializeToTreeNodeMixin, NodeChildrenApi):
|
|||
if not self.instance or not include_assets:
|
||||
return Asset.objects.none()
|
||||
if query_all:
|
||||
assets = self.instance.get_all_assets_for_tree()
|
||||
assets = self.instance.get_all_assets()
|
||||
else:
|
||||
assets = self.instance.get_assets_for_tree()
|
||||
return assets
|
||||
assets = self.instance.get_assets()
|
||||
return assets.only(
|
||||
"id", "name", "address", "platform_id",
|
||||
"org_id", "is_active", 'comment'
|
||||
).prefetch_related('platform')
|
||||
|
||||
def filter_queryset_for_assets(self, assets):
|
||||
search = self.request.query_params.get('search')
|
||||
|
|
|
@ -429,18 +429,6 @@ class NodeAssetsMixin(NodeAllAssetsMappingMixin):
|
|||
assets = Asset.objects.filter(nodes=self)
|
||||
return assets.distinct()
|
||||
|
||||
def get_assets_for_tree(self):
|
||||
return self.get_assets().only(
|
||||
"id", "name", "address", "platform_id",
|
||||
"org_id", "is_active"
|
||||
).prefetch_related('platform')
|
||||
|
||||
def get_all_assets_for_tree(self):
|
||||
return self.get_all_assets().only(
|
||||
"id", "name", "address", "platform_id",
|
||||
"org_id", "is_active"
|
||||
).prefetch_related('platform')
|
||||
|
||||
def get_valid_assets(self):
|
||||
return self.get_assets().valid()
|
||||
|
||||
|
|
Loading…
Reference in New Issue