fix: correctly add nodes to chunks [COG-1370] (#568)

<!-- .github/pull_request_template.md -->

## Description
- Fix expand_with_nodes_and_edges to correctly add nodes to chunks
## DCO Affirmation
I affirm that all code in every commit of this pull request conforms to
the terms of the Topoteretes Developer Certificate of Origin


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Refactor**
- Enhanced the internal processing for data associations to ensure more
reliable and consistent handling of connections.
- Streamlined the logic to better manage edge cases, improving overall
stability and error handling.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
lxobr 2025-02-20 12:52:34 +01:00 committed by GitHub
parent f2e0f47565
commit e25c7c93fe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -19,6 +19,7 @@ def expand_with_nodes_and_edges(
existing_edges_map = {}
added_nodes_map = {}
relationships = []
for index, data_chunk in enumerate(data_chunks):
@ -53,12 +54,14 @@ def expand_with_nodes_and_edges(
description=node.description,
)
if data_chunk.contains is None:
data_chunk.contains = []
data_chunk.contains.append(entity_node)
added_nodes_map[f"{str(node_id)}_entity"] = entity_node
else:
entity_node = added_nodes_map[f"{str(node_id)}_entity"]
if data_chunk.contains is None:
data_chunk.contains = []
data_chunk.contains.append(entity_node)
# Add relationship that came from graphs.
for edge in graph.edges: