Collapse duplicate repository graph nodes

This commit is contained in:
2026-05-21 01:04:22 +02:00
parent a8e67db9e9
commit 072fa8f7a7
3 changed files with 103 additions and 2 deletions

View File

@@ -238,6 +238,13 @@ def fabric_graph_explorer_payload(
elements: list[dict[str, Any]] = []
repository_index = {str(repo.get("slug", "")): repo for repo in repositories}
source_repository_node_ids = {
str(node.get("id", "")): f"repo:{str(node.get('repo', '')).strip()}"
for node in source_nodes
if str(node.get("kind", "")) == "Repository"
and str(node.get("id", ""))
and str(node.get("repo", "")).strip()
}
for slug in sorted(repo_slugs):
repo = repository_index.get(slug, {})
has_snapshot = slug in snapshot_repo_slugs or slug in source_repo_slugs
@@ -281,6 +288,8 @@ def fabric_graph_explorer_payload(
if not node_id:
continue
kind = str(node.get("kind", ""))
if kind == "Repository":
continue
layer = _layer_for_kind(kind)
is_unresolved = node_id in unresolved
attributes = node.get("attributes") if isinstance(node.get("attributes"), dict) else {}
@@ -342,8 +351,8 @@ def fabric_graph_explorer_payload(
)
for edge in source_edges:
source = str(edge.get("from", ""))
target = str(edge.get("to", ""))
source = source_repository_node_ids.get(str(edge.get("from", "")), str(edge.get("from", "")))
target = source_repository_node_ids.get(str(edge.get("to", "")), str(edge.get("to", "")))
edge_type = str(edge.get("type", ""))
if not source or not target:
continue
@@ -354,6 +363,8 @@ def fabric_graph_explorer_payload(
repo_id = f"repo:{slug}"
for node in source_nodes:
node_id = str(node.get("id", ""))
if str(node.get("kind", "")) == "Repository":
continue
if str(node.get("repo", "")) != slug or not node_id:
continue
elements.append(_edge_element(edge_index, repo_id, node_id, "declares", node_layers, node_repos))