@@ -552,6 +552,7 @@ def publish(self, instance, with_valid=True):
552
552
dataset_list = self .list_dataset (with_valid = False )
553
553
dataset_id_list = self .update_reverse_search_node (work_flow ,
554
554
[str (dataset .get ('id' )) for dataset in dataset_list ])
555
+
555
556
application .work_flow = work_flow
556
557
application .save ()
557
558
# 插入知识库关联关系
@@ -589,7 +590,7 @@ def update_search_node(self, work_flow, user_dataset_id_list: List):
589
590
590
591
def update_reverse_search_node (self , work_flow , user_dataset_id_list : List ):
591
592
search_node_list = self .get_search_node (work_flow )
592
- dataset_id_list = []
593
+ result_dataset_id_list = []
593
594
for search_node in search_node_list :
594
595
node_data = search_node .get ('properties' , {}).get ('node_data' , {})
595
596
dataset_id_list = node_data .get ('dataset_id_list' , [])
@@ -603,8 +604,8 @@ def update_reverse_search_node(self, work_flow, user_dataset_id_list: List):
603
604
source_dataset_id_list = list ({* source_dataset_id_list , * dataset_id_list })
604
605
node_data ['source_dataset_id_list' ] = []
605
606
node_data ['dataset_id_list' ] = source_dataset_id_list
606
- dataset_id_list = [* source_dataset_id_list , * dataset_id_list ]
607
- return list (set (dataset_id_list ))
607
+ result_dataset_id_list = [* source_dataset_id_list , * result_dataset_id_list ]
608
+ return list (set (result_dataset_id_list ))
608
609
609
610
def profile (self , with_valid = True ):
610
611
if with_valid :
@@ -667,6 +668,8 @@ def edit(self, instance: Dict, with_valid=True):
667
668
668
669
@staticmethod
669
670
def save_application_mapping (dataset_id_list , application_id ):
671
+ # 需要排除已删除的数据集
672
+ dataset_id_list = [dataset .id for dataset in QuerySet (DataSet ).filter (id__in = dataset_id_list )]
670
673
# 删除已经关联的id
671
674
QuerySet (ApplicationDatasetMapping ).filter (dataset_id__in = dataset_id_list ,
672
675
application_id = application_id ).delete ()
0 commit comments