perf: Asset filter

This commit is contained in:
feng 2025-04-15 15:51:46 +08:00 committed by Bryan
parent 9b1bff0847
commit 631570b819
2 changed files with 3 additions and 2 deletions

View File

@ -173,7 +173,8 @@ class AssetViewSet(SuggestionMixin, BaseAssetViewSet):
@action(methods=["GET"], detail=True, url_path="accounts")
def accounts(self, *args, **kwargs):
asset = super().get_object()
pk = self.kwargs.get("pk")
asset = get_object_or_404(self.model, pk=pk)
queryset = asset.all_accounts.all()
return self.get_paginated_response_from_queryset(queryset)

View File

@ -261,7 +261,7 @@ class Asset(NodesRelationMixin, LabeledMixin, AbsConnectivity, JSONFilterMixin,
@lazyproperty
def accounts_amount(self):
return self.accounts.count()
return self.all_accounts.count()
def get_target_ip(self):
return self.address