Commit 5bc66274 by Adam Committed by GitHub

Merge pull request #15849 from edx/fix-cg-dangling-pointer

have coursegraph cache nodes on block_ids rather than locations (EDUC…
parents 2298bd25 67d2ef6e
......@@ -167,17 +167,18 @@ def serialize_course(course_id):
fields[field_name] = coerce_types(value)
node = Node(block_type, 'item', **fields)
location_to_node[item.location] = node
location_to_node[item.location.block_id] = node
# create relationships
relationships = []
for item in items:
previous_child_node = None
for index, child_loc in enumerate(item.get_children()):
parent_node = location_to_node.get(item.location)
child_node = location_to_node.get(child_loc.location)
child_node["index"] = index
for index, child in enumerate(item.get_children()):
parent_node = location_to_node.get(item.location.block_id)
child_node = location_to_node.get(child.location.block_id)
if parent_node is not None and child_node is not None:
child_node["index"] = index
relationship = Relationship(parent_node, "PARENT_OF", child_node)
relationships.append(relationship)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment