perf: 单独推送账号

pull/10209/head
feng 2023-04-14 15:34:56 +08:00 committed by Jiangjie.Bai
parent 976daaa726
commit 31653cab11
2 changed files with 7 additions and 2 deletions

View File

@ -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

View File

@ -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'}
)