perf: change secret drop bulk record

This commit is contained in:
feng
2025-03-11 17:37:04 +08:00
parent 5571fb6f42
commit 59e7778e4a
8 changed files with 11 additions and 38 deletions

View File

@@ -79,13 +79,9 @@ class ChangeSecretDashboardApi(APIView):
def change_secrets_queryset(self):
return ChangeSecretAutomation.objects.all()
@lazyproperty
def change_secret_executions_queryset(self):
return AutomationExecution.objects.filter(automation__type=self.tp)
@lazyproperty
def change_secret_records_queryset(self):
return ChangeSecretRecord.get_valid_records().filter(execution__automation__type=self.tp)
return ChangeSecretRecord.get_valid_records()
def get_change_secret_asset_queryset(self):
qs = self.change_secrets_queryset
@@ -159,8 +155,7 @@ class ChangeSecretDashboardApi(APIView):
if name == self.task_name and tp == self.tp:
execution_ids.append(_id)
snapshots = self.change_secret_executions_queryset.filter(
id__in=execution_ids).values_list('id', 'snapshot')
snapshots = AutomationExecution.objects.filter(id__in=execution_ids).values_list('id', 'snapshot')
asset_ids = {asset for i in snapshots for asset in i.get('assets', [])}
account_ids = {account for i in snapshots for account in i.get('accounts', [])}