From 6b42bdb0ef51d5cb142c565a37ad82b81016965d Mon Sep 17 00:00:00 2001 From: Stuart Axelbrooke Date: Wed, 3 Dec 2025 23:04:16 -0800 Subject: [PATCH] add stroke colors to mermaid --- databuild/lineage.rs | 47 ++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/databuild/lineage.rs b/databuild/lineage.rs index 63bd9c8..7005e44 100644 --- a/databuild/lineage.rs +++ b/databuild/lineage.rs @@ -24,7 +24,8 @@ pub struct LineageNode { pub id: String, pub label: String, pub node_type: LineageNodeType, - pub status_color: String, + pub status_fill: String, + pub status_stroke: String, pub url: String, } @@ -93,8 +94,8 @@ impl LineageGraph { // Add styles for status colors for node in &self.nodes { - if !node.status_color.is_empty() { - lines.push(format!(" style {} fill:{}", node.id, node.status_color)); + if !node.status_fill.is_empty() { + lines.push(format!(" style {} fill:{},stroke:{}", node.id, node.status_fill, node.status_stroke)); } } @@ -117,7 +118,7 @@ impl LineageGraph { /// Map status names to colors for the lineage graph. /// Status names are matched case-insensitively against proto-generated enum names. -pub fn status_to_color(status_name: &str) -> &'static str { +pub fn status_to_fill(status_name: &str) -> &'static str { match status_name.to_lowercase().as_str() { "wantsuccessful" | "partitionlive" | "jobrunsucceeded" => "#dcfce7", // green "wantbuilding" | "partitionbuilding" | "jobrunrunning" => "#ede9fe", // blue @@ -131,6 +132,20 @@ pub fn status_to_color(status_name: &str) -> &'static str { } } +pub fn status_to_stroke(status_name: &str) -> &'static str { + match status_name.to_lowercase().as_str() { + "wantsuccessful" | "partitionlive" | "jobrunsucceeded" => "#22c55e", // green-500 + "wantbuilding" | "partitionbuilding" | "jobrunrunning" => "#8b5cf6", // violet-500 + "wantidle" | "jobrunqueued" => "#6b7280", // gray-500 + "wantfailed" | "partitionfailed" | "jobrunfailed" => "#ef4444", // red-500 + "wantdepmiss" | "jobrundepmiss" => "#f59e0b", // amber-500 + "wantupstreamfailed" | "partitionupstreamfailed" => "#ef4444", // red-500 + "wantcanceled" | "jobruncanceled" => "#4b5563", // gray-600 + "wantupstreambuilding" | "partitionupstreambuilding" => "#7c3aed", // violet-600 + _ => "#9ca3af", // gray-400 default + } +} + // ============================================================================= // Graph Builder // ============================================================================= @@ -169,9 +184,10 @@ pub fn build_lineage_graph( // Add want node graph.add_node(LineageNode { id: want_node_id.clone(), - label: truncate_label(want_id, 30), + label: truncate_label(want_id, 50), node_type: LineageNodeType::Want, - status_color: status_to_color(status_name).to_string(), + status_fill: status_to_fill(status_name).to_string(), + status_stroke: status_to_stroke(status_name).to_string(), url: format!("/wants/{}", want_id), }); @@ -189,9 +205,10 @@ pub fn build_lineage_graph( graph.add_node(LineageNode { id: partition_node_id.clone(), - label: truncate_label(partition_ref, 25), + label: truncate_label(partition_ref, 50), node_type: LineageNodeType::Partition, - status_color: status_to_color(&partition_status).to_string(), + status_fill: status_to_fill(&partition_status).to_string(), + status_stroke: status_to_stroke(&partition_status).to_string(), url: format!("/partitions/{}", urlencoding::encode(partition_ref)), }); @@ -217,9 +234,10 @@ pub fn build_lineage_graph( graph.add_node(LineageNode { id: job_run_node_id.clone(), - label: truncate_label(job_label, 25), + label: truncate_label(job_label, 50), node_type: LineageNodeType::JobRun, - status_color: status_to_color(job_status_name).to_string(), + status_fill: status_to_fill(job_status_name).to_string(), + status_stroke: status_to_stroke(job_status_name).to_string(), url: format!("/job_runs/{}", job_run.id), }); @@ -302,7 +320,8 @@ mod tests { id: "W_beta_want".to_string(), label: "beta-want".to_string(), node_type: LineageNodeType::Want, - status_color: "#22c55e".to_string(), + status_fill: "#22c55e".to_string(), + status_stroke: "#22c55e".to_string(), url: "/wants/beta-want".to_string(), }); @@ -310,7 +329,8 @@ mod tests { id: "P_data_beta".to_string(), label: "data/beta".to_string(), node_type: LineageNodeType::Partition, - status_color: "#22c55e".to_string(), + status_fill: "#22c55e".to_string(), + status_stroke: "#22c55e".to_string(), url: "/partitions/data%2Fbeta".to_string(), }); @@ -318,7 +338,8 @@ mod tests { id: "JR_beta_job".to_string(), label: "//job_beta".to_string(), node_type: LineageNodeType::JobRun, - status_color: "#f97316".to_string(), + status_fill: "#f97316".to_string(), + status_stroke: "#f97316".to_string(), url: "/job_runs/beta-job".to_string(), });