From 3af188492fe02588e84813292b41c6b03b31cde8 Mon Sep 17 00:00:00 2001 From: wangruidong <940853815@qq.com> Date: Wed, 16 Jul 2025 19:07:00 +0800 Subject: [PATCH] fix: Gather account failed --- apps/accounts/automations/gather_account/manager.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/accounts/automations/gather_account/manager.py b/apps/accounts/automations/gather_account/manager.py index c5598d806..eb36e39e8 100644 --- a/apps/accounts/automations/gather_account/manager.py +++ b/apps/accounts/automations/gather_account/manager.py @@ -390,6 +390,9 @@ class GatherAccountsManager(AccountBasePlaybookManager): self.update_gathered_account(ori_account, d) ori_found = username in ori_users need_analyser_gather_account.append((asset, ga, d, ori_found)) + # 这里顺序不能调整,risk 外键关联了 gathered_account 主键 id,所以在创建 risk 需要保证 gathered_account 已经创建完成 + self.create_gathered_account.finish() + self.update_gathered_account.finish() for analysis_data in need_analyser_gather_account: risk_analyser.analyse_risk(*analysis_data) self.update_gather_accounts_status(asset) @@ -403,8 +406,6 @@ class GatherAccountsManager(AccountBasePlaybookManager): present=True ) # 因为有 bulk create, bulk update, 所以这里需要 sleep 一下,等待数据同步 - self.create_gathered_account.finish() - self.update_gathered_account.finish() _update_risk.finish() _create_risk.finish()