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
commit bccf3a0340
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

Loading…
Cancel
Save