From 10b033ee97c2375a2fc173cd52b4ca732339fa7e Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Thu, 20 Apr 2023 16:22:02 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E6=89=B9=E9=87=8F=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E8=B5=84=E4=BA=A7=E6=B6=88=E6=81=AF=20(#10280)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: feng <1304903146@qq.com> --- apps/assets/api/asset/asset.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/assets/api/asset/asset.py b/apps/assets/api/asset/asset.py index 469c2a95f..ba048e236 100644 --- a/apps/assets/api/asset/asset.py +++ b/apps/assets/api/asset/asset.py @@ -111,7 +111,6 @@ class AssetViewSet(SuggestionMixin, NodeFilterMixin, OrgBulkModelViewSet): ("gathered_info", "assets.view_asset"), ) extra_filter_backends = [LabelFilterBackend, IpInFilterBackend, NodeFilterBackend] - skip_assets = [] def get_serializer_class(self): cls = super().get_serializer_class() @@ -144,6 +143,7 @@ class AssetViewSet(SuggestionMixin, NodeFilterMixin, OrgBulkModelViewSet): def filter_bulk_update_data(self): bulk_data = [] + skip_assets = [] for data in self.request.data: pk = data.get('id') platform = data.get('platform') @@ -155,16 +155,16 @@ class AssetViewSet(SuggestionMixin, NodeFilterMixin, OrgBulkModelViewSet): if platform.type == asset.type: bulk_data.append(data) continue - self.skip_assets.append(asset) - return bulk_data + skip_assets.append(asset) + return bulk_data, skip_assets def bulk_update(self, request, *args, **kwargs): - bulk_data = self.filter_bulk_update_data() + bulk_data, skip_assets = self.filter_bulk_update_data() request._full_data = bulk_data response = super().bulk_update(request, *args, **kwargs) - if response.status_code == HTTP_200_OK and self.skip_assets: + if response.status_code == HTTP_200_OK and skip_assets: user = request.user - BulkUpdatePlatformSkipAssetUserMsg(user, self.skip_assets).publish() + BulkUpdatePlatformSkipAssetUserMsg(user, skip_assets).publish() return response