Commit 67d2ef6e by Adam Palay

have coursegraph cache nodes on block_ids rather than locations (EDUCATOR-1133)

parent 36e4c801
...@@ -167,17 +167,18 @@ def serialize_course(course_id): ...@@ -167,17 +167,18 @@ def serialize_course(course_id):
fields[field_name] = coerce_types(value) fields[field_name] = coerce_types(value)
node = Node(block_type, 'item', **fields) node = Node(block_type, 'item', **fields)
location_to_node[item.location] = node location_to_node[item.location.block_id] = node
# create relationships # create relationships
relationships = [] relationships = []
for item in items: for item in items:
previous_child_node = None previous_child_node = None
for index, child_loc in enumerate(item.get_children()): for index, child in enumerate(item.get_children()):
parent_node = location_to_node.get(item.location) parent_node = location_to_node.get(item.location.block_id)
child_node = location_to_node.get(child_loc.location) child_node = location_to_node.get(child.location.block_id)
child_node["index"] = index
if parent_node is not None and child_node is not None: if parent_node is not None and child_node is not None:
child_node["index"] = index
relationship = Relationship(parent_node, "PARENT_OF", child_node) relationship = Relationship(parent_node, "PARENT_OF", child_node)
relationships.append(relationship) 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