Browse Source

perf: 单独推送账号

pull/10209/head
feng 2 years ago committed by Jiangjie.Bai
parent
commit
31653cab11
  1. 3
      apps/accounts/api/account/task.py
  2. 6
      apps/accounts/serializers/account/account.py

3
apps/accounts/api/account/task.py

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

6
apps/accounts/serializers/account/account.py

@ -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…
Cancel
Save