feat: 获取batchlog dag数据支持临近节点返回
This commit is contained in:
parent
adee19eb5b
commit
81aa49d339
|
|
@ -1081,11 +1081,49 @@ def get_batch_dag(batch_number: str, method="full"):
|
||||||
logs = BatchLog.objects.filter(Q(source__id=batch_ins.id) | Q(target__id=batch_ins.id)).select_related(
|
logs = BatchLog.objects.filter(Q(source__id=batch_ins.id) | Q(target__id=batch_ins.id)).select_related(
|
||||||
"source", "target"
|
"source", "target"
|
||||||
).order_by("update_time")
|
).order_by("update_time")
|
||||||
|
|
||||||
|
exist_log_ids = []
|
||||||
|
left_source_ids = []
|
||||||
|
right_target_ids = []
|
||||||
for log in logs:
|
for log in logs:
|
||||||
|
exist_log_ids.append(log.id)
|
||||||
source = log.source.id
|
source = log.source.id
|
||||||
target = log.target.id
|
target = log.target.id
|
||||||
nodes_set.update([source, target])
|
if source == batch_ins.id:
|
||||||
|
right_target_ids.append(target)
|
||||||
|
nodes_set.add(target)
|
||||||
|
if target == batch_ins.id:
|
||||||
|
left_source_ids.append(source)
|
||||||
|
nodes_set.add(source)
|
||||||
|
edges.append({
|
||||||
|
'id': log.id,
|
||||||
|
'source': source,
|
||||||
|
'target': target,
|
||||||
|
"handover": log.handover.id if log.handover else None,
|
||||||
|
"mlog": log.mlog.id if log.mlog else None,
|
||||||
|
'label': r_dict.get(log.relation_type, ""),
|
||||||
|
})
|
||||||
|
|
||||||
|
# 查询作为source的其他关系
|
||||||
|
leftLogs = BatchLog.objects.filter(source_id__in=left_source_ids).exclude(id__in=exist_log_ids)
|
||||||
|
for log in leftLogs:
|
||||||
|
source = log.source.id
|
||||||
|
target = log.target.id
|
||||||
|
nodes_set.add(log.target.id)
|
||||||
|
edges.append({
|
||||||
|
'id': log.id,
|
||||||
|
'source': source,
|
||||||
|
'target': target,
|
||||||
|
"handover": log.handover.id if log.handover else None,
|
||||||
|
"mlog": log.mlog.id if log.mlog else None,
|
||||||
|
'label': r_dict.get(log.relation_type, ""),
|
||||||
|
})
|
||||||
|
|
||||||
|
rightLogs = BatchLog.objects.filter(target_id__in=right_target_ids).exclude(id__in=exist_log_ids)
|
||||||
|
for log in rightLogs:
|
||||||
|
source = log.source.id
|
||||||
|
target = log.target.id
|
||||||
|
nodes_set.add(log.source.id)
|
||||||
edges.append({
|
edges.append({
|
||||||
'id': log.id,
|
'id': log.id,
|
||||||
'source': source,
|
'source': source,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue