From 827c8296580f9970eca35537ee57ccb6d71bca2d Mon Sep 17 00:00:00 2001 From: wangruidong <940853815@qq.com> Date: Fri, 3 Jan 2025 15:05:43 +0800 Subject: [PATCH] fix: gather account sync account to asset --- apps/accounts/automations/gather_account/manager.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/accounts/automations/gather_account/manager.py b/apps/accounts/automations/gather_account/manager.py index fb0c819fa..c52a72a35 100644 --- a/apps/accounts/automations/gather_account/manager.py +++ b/apps/accounts/automations/gather_account/manager.py @@ -358,7 +358,6 @@ class GatherAccountsManager(AccountBasePlaybookManager): for asset, accounts_data in self.asset_account_info.items(): ori_users = self.ori_asset_usernames[str(asset.id)] with tmp_to_org(asset.org_id): - gathered_accounts = [] for d in accounts_data: username = d["username"] ori_account = self.ori_gathered_accounts_mapper.get( @@ -374,6 +373,9 @@ class GatherAccountsManager(AccountBasePlaybookManager): self.create_gathered_account.finish() self.update_gathered_account.finish() self.update_gather_accounts_status(asset) + if not self.is_sync_account: + continue + gathered_accounts = GatheredAccount.objects.filter(asset=asset) GatheredAccount.sync_accounts(gathered_accounts, self.is_sync_account) # 因为有 bulk create, bulk update, 所以这里需要 sleep 一下,等待数据同步 time.sleep(0.5)