From 67d2ef6ebbac0b7d1ef8ba4d116de72fb5468c57 Mon Sep 17 00:00:00 2001 From: Adam Palay Date: Fri, 18 Aug 2017 11:45:16 -0400 Subject: [PATCH] have coursegraph cache nodes on block_ids rather than locations (EDUCATOR-1133) --- openedx/core/djangoapps/coursegraph/tasks.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/openedx/core/djangoapps/coursegraph/tasks.py b/openedx/core/djangoapps/coursegraph/tasks.py index c8c0d23df3..9138612ae7 100644 --- a/openedx/core/djangoapps/coursegraph/tasks.py +++ b/openedx/core/djangoapps/coursegraph/tasks.py @@ -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)