Browse Source

Merge pull request #10819 from jumpserver/pr@dev@perf_asset_asset

perf: 接口sql优化 /api/v1/assets/assets/
pull/10825/head
老广 1 year ago committed by GitHub
parent
commit
bccf3a0340
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      apps/assets/api/asset/asset.py

4
apps/assets/api/asset/asset.py

@ -121,6 +121,10 @@ class AssetViewSet(SuggestionMixin, NodeFilterMixin, OrgBulkModelViewSet):
NodeFilterBackend, AttrRulesFilterBackend
]
def get_queryset(self):
return super().get_queryset().prefetch_related('nodes', 'protocols')\
.select_related('platform', 'domain')
def get_serializer_class(self):
cls = super().get_serializer_class()
if self.action == "retrieve":

Loading…
Cancel
Save