Fix mermaid edge duplication
Some checks are pending
/ setup (push) Waiting to run

This commit is contained in:
soaxelbrooke 2025-07-16 19:22:03 -07:00
parent ad15ffc3c8
commit 327909395e

View file

@ -89,6 +89,7 @@ pub fn generate_mermaid_with_status(
// Track nodes we've already added to avoid duplicates
let mut added_nodes = HashSet::new();
let mut added_refs = HashSet::new();
let mut added_edges = HashSet::new();
// Map to track which refs are outputs (to highlight them)
let mut is_output_ref = HashSet::new();
@ -152,13 +153,22 @@ pub fn generate_mermaid_with_status(
added_refs.insert(ref_node_id.clone());
}
// Add the edge from input to job
// Add the edge from input to job (avoid duplicates)
let edge_key = if input.dep_type == 1 { // MATERIALIZE = 1
format!("{}-->{}", ref_node_id, job_node_id)
} else {
format!("{}-.->{}", ref_node_id, job_node_id)
};
if !added_edges.contains(&edge_key) {
if input.dep_type == 1 { // MATERIALIZE = 1
mermaid.push_str(&format!(" {} --> {}\n", ref_node_id, job_node_id));
} else {
// Dashed line for query dependencies
mermaid.push_str(&format!(" {} -.-> {}\n", ref_node_id, job_node_id));
}
added_edges.insert(edge_key);
}
}
}
@ -184,8 +194,12 @@ pub fn generate_mermaid_with_status(
added_refs.insert(ref_node_id.clone());
}
// Add the edge from job to output
// Add the edge from job to output (avoid duplicates)
let edge_key = format!("{}-->{}", job_node_id, ref_node_id);
if !added_edges.contains(&edge_key) {
mermaid.push_str(&format!(" {} --> {}\n", job_node_id, ref_node_id));
added_edges.insert(edge_key);
}
}
}
}