MCPcopy Create free account
hub / github.com/TabularisDB/tabularis / explainPlanToFlow

Function explainPlanToFlow

src/utils/explainPlan.ts:10–53  ·  view source on GitHub ↗
(
  plan: ExplainPlan,
  selectedNodeId?: string | null,
)

Source from the content-addressed store, hash-verified

8// ---------------------------------------------------------------------------
9
10export function explainPlanToFlow(
11 plan: ExplainPlan,
12 selectedNodeId?: string | null,
13): {
14 nodes: Node[];
15 edges: Edge[];
16} {
17 const maxCost = getMaxCost(plan.root);
18 const maxTime = getMaxTime(plan.root);
19 const rawNodes: Node[] = [];
20 const edges: Edge[] = [];
21
22 function walk(node: ExplainNode) {
23 const data: ExplainPlanNodeData = {
24 node,
25 maxCost,
26 maxTime,
27 hasAnalyzeData: plan.has_analyze_data,
28 isSelected: selectedNodeId === node.id,
29 };
30
31 rawNodes.push({
32 id: node.id,
33 type: "explainPlan",
34 position: { x: 0, y: 0 },
35 data,
36 });
37
38 for (const child of node.children) {
39 edges.push({
40 id: `${node.id}-${child.id}`,
41 source: node.id,
42 target: child.id,
43 animated: true,
44 style: { stroke: "#6366f1" },
45 });
46 walk(child);
47 }
48 }
49
50 walk(plan.root);
51
52 return layoutExplainNodes(rawNodes, edges);
53}
54
55// ---------------------------------------------------------------------------
56// Dagre layout

Callers 2

ExplainGraphInnerFunction · 0.90

Calls 4

getMaxCostFunction · 0.85
getMaxTimeFunction · 0.85
layoutExplainNodesFunction · 0.85
walkFunction · 0.70

Tested by

no test coverage detected