Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

Commit

Permalink
fix: move xblock tree location to top level
Browse files Browse the repository at this point in the history
Parsing down the tree is vastly slower for some reason.
  • Loading branch information
bmtcril committed Sep 29, 2023
1 parent 15358bd commit 00efb51
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
8 changes: 3 additions & 5 deletions event_sink_clickhouse/sinks/course_published.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,9 @@ def serialize_item(self, item, many=False, initial=None):
elif fields["xblock_data_json"]["block_type"] == "vertical":
unit_idx += 1

fields["xblock_data_json"]["course_tree_location"] = {
"section": section_idx,
"subsection": subsection_idx,
"unit": unit_idx
}
fields["xblock_data_json"]["section"] = section_idx
fields["xblock_data_json"]["subsection"] = subsection_idx
fields["xblock_data_json"]["unit"] = unit_idx

fields["xblock_data_json"] = json.dumps(fields["xblock_data_json"])
location_to_node[
Expand Down
6 changes: 3 additions & 3 deletions tests/test_course_published.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,9 @@ def _check_tree_location(block, expected_section=0, expected_subsection=0, expec
"""
try:
j = json.loads(block["xblock_data_json"])
assert j["course_tree_location"]["section"] == expected_section
assert j["course_tree_location"]["subsection"] == expected_subsection
assert j["course_tree_location"]["unit"] == expected_unit
assert j["section"] == expected_section
assert j["subsection"] == expected_subsection
assert j["unit"] == expected_unit
except AssertionError as e:
print(e)
print(block)
Expand Down

0 comments on commit 00efb51

Please sign in to comment.