Skip to content

Commit f3bf9e2

Browse files
authored
fix: The application export loop node cannot be used (#4268)
1 parent aaa0dab commit f3bf9e2

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

apps/application/serializers/application.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ def get_base_node_work_flow(work_flow):
5858
return None
5959

6060

61+
def hand_node(node, update_tool_map):
62+
if node.get('type') == 'tool-lib-node':
63+
tool_lib_id = (node.get('properties', {}).get('node_data', {}).get('tool_lib_id') or '')
64+
node.get('properties', {}).get('node_data', {})['tool_lib_id'] = update_tool_map.get(tool_lib_id,
65+
tool_lib_id)
66+
if node.get('type') == 'search-knowledge-node':
67+
node.get('properties', {}).get('node_data', {})['knowledge_id_list'] = []
68+
69+
6170
class MKInstance:
6271

6372
def __init__(self, application: dict, function_lib_list: List[dict], version: str, tool_list: List[dict]):
@@ -348,9 +357,9 @@ def get_query_set(self, instance: Dict, workspace_manage: bool, is_x_pack_ee: bo
348357
application_query_set = application_query_set.order_by("-create_time")
349358

350359
resource_and_folder_query_set = QuerySet(WorkspaceUserResourcePermission).filter(
351-
auth_target_type="APPLICATION",
352-
workspace_id=workspace_id,
353-
user_id=user_id)
360+
auth_target_type="APPLICATION",
361+
workspace_id=workspace_id,
362+
user_id=user_id)
354363

355364
return {'application_query_set': application_query_set,
356365
'workspace_user_resource_permission_query_set': resource_and_folder_query_set,
@@ -582,12 +591,10 @@ def to_tool(tool, workspace_id, user_id):
582591
def to_application(application, workspace_id, user_id, update_tool_map, folder_id):
583592
work_flow = application.get('work_flow')
584593
for node in work_flow.get('nodes', []):
585-
if node.get('type') == 'tool-lib-node':
586-
tool_lib_id = (node.get('properties', {}).get('node_data', {}).get('tool_lib_id') or '')
587-
node.get('properties', {}).get('node_data', {})['tool_lib_id'] = update_tool_map.get(tool_lib_id,
588-
tool_lib_id)
589-
if node.get('type') == 'search-knowledge-node':
590-
node.get('properties', {}).get('node_data', {})['knowledge_id_list'] = []
594+
hand_node(node, update_tool_map)
595+
if node.get('type') == 'loop-node':
596+
for n in node.get('properties', {}).get('node_data', {}).get('loop_body', {}).get('nodes', []):
597+
hand_node(n, update_tool_map)
591598
return Application(id=uuid.uuid7(),
592599
user_id=user_id,
593600
name=application.get('name'),

0 commit comments

Comments
 (0)