mirror of https://github.com/jumpserver/jumpserver
perf: 单独推送账号
parent
976daaa726
commit
31653cab11
|
@ -24,10 +24,11 @@ class AccountsTaskCreateAPI(CreateAPIView):
|
|||
def perform_create(self, serializer):
|
||||
data = serializer.validated_data
|
||||
accounts = data.get('accounts', [])
|
||||
params = data.get('params')
|
||||
account_ids = [str(a.id) for a in accounts]
|
||||
|
||||
if data['action'] == 'push':
|
||||
task = push_accounts_to_assets_task.delay(account_ids)
|
||||
task = push_accounts_to_assets_task.delay(account_ids, params)
|
||||
else:
|
||||
account = accounts[0]
|
||||
asset = account.asset
|
||||
|
|
|
@ -97,7 +97,7 @@ class AccountCreateUpdateSerializerMixin(serializers.Serializer):
|
|||
|
||||
@staticmethod
|
||||
def push_account_if_need(instance, push_now, params, stat):
|
||||
if not push_now or stat != 'created':
|
||||
if not push_now or stat not in ['created', 'updated']:
|
||||
return
|
||||
push_accounts_to_assets_task.delay([str(instance.id)], params)
|
||||
|
||||
|
@ -404,3 +404,7 @@ class AccountTaskSerializer(serializers.Serializer):
|
|||
queryset=Account.objects, required=False, allow_empty=True, many=True
|
||||
)
|
||||
task = serializers.CharField(read_only=True)
|
||||
params = serializers.JSONField(
|
||||
decoder=None, encoder=None, required=False,
|
||||
style={'base_template': 'textarea.html'}
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue