feat: get_batch_dag还是只返回直接前后级别

This commit is contained in:
caoqianming 2026-01-04 13:55:09 +08:00
parent 9ed78f8d32
commit 952cdb1bc7
1 changed files with 27 additions and 26 deletions

View File

@ -1062,6 +1062,7 @@ def get_batch_dag(batch_number: str, method="full"):
} }
if method == "full": if method == "full":
raise ParseError("不支持获取全局关系链条")
# 完整DAG模式 - 收集所有相关批次和边(原逻辑) # 完整DAG模式 - 收集所有相关批次和边(原逻辑)
nodes_set = {batch_ins.id} nodes_set = {batch_ins.id}
edges = [] edges = []
@ -1118,33 +1119,33 @@ def get_batch_dag(batch_number: str, method="full"):
}) })
# 查询作为source的其他关系 # 查询作为source的其他关系
leftLogs = BatchLog.objects.filter(source_id__in=left_source_ids).exclude(id__in=exist_log_ids) # leftLogs = BatchLog.objects.filter(source_id__in=left_source_ids).exclude(id__in=exist_log_ids)
for log in leftLogs: # for log in leftLogs:
source = log.source.id # source = log.source.id
target = log.target.id # target = log.target.id
nodes_set.add(log.target.id) # nodes_set.add(log.target.id)
edges.append({ # edges.append({
'id': log.id, # 'id': log.id,
'source': source, # 'source': source,
'target': target, # 'target': target,
"handover": log.handover.id if log.handover else None, # "handover": log.handover.id if log.handover else None,
"mlog": log.mlog.id if log.mlog else None, # "mlog": log.mlog.id if log.mlog else None,
'label': r_dict.get(log.relation_type, ""), # 'label': r_dict.get(log.relation_type, ""),
}) # })
rightLogs = BatchLog.objects.filter(target_id__in=right_target_ids).exclude(id__in=exist_log_ids) # rightLogs = BatchLog.objects.filter(target_id__in=right_target_ids).exclude(id__in=exist_log_ids)
for log in rightLogs: # for log in rightLogs:
source = log.source.id # source = log.source.id
target = log.target.id # target = log.target.id
nodes_set.add(log.source.id) # nodes_set.add(log.source.id)
edges.append({ # edges.append({
'id': log.id, # 'id': log.id,
'source': source, # 'source': source,
'target': target, # 'target': target,
"handover": log.handover.id if log.handover else None, # "handover": log.handover.id if log.handover else None,
"mlog": log.mlog.id if log.mlog else None, # "mlog": log.mlog.id if log.mlog else None,
'label': r_dict.get(log.relation_type, ""), # 'label': r_dict.get(log.relation_type, ""),
}) # })
else: else:
raise ParseError("不支持的查询方法,请使用'full''direct'") raise ParseError("不支持的查询方法,请使用'full''direct'")