Skip to content

Commit 3b46e50

Browse files
committed
fix: newly created children lack is_external
1 parent b201aa9 commit 3b46e50

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

backend/editor/controllers/node_controller.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ async def create_entry_node(
4040
f"tags_{language_code}": [name],
4141
f"tags_ids_{language_code}": [normalized_name],
4242
"modified": datetime.datetime.now().timestamp(),
43+
"is_external": False,
4344
}
4445
params = {"entry_node": entry_node_data}
4546

backend/tests/test_export.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,30 @@ async def test_no_comment_repeat(taxonomy_test):
167167
background_tasks.run()
168168

169169

170+
@pytest.mark.anyio
171+
async def test_add_bare_child(taxonomy_test):
172+
async with graph_db.TransactionCtx():
173+
# add a children to "en:yogurts", without any other properties
174+
children = await taxonomy_test.get_children("en:yogurts")
175+
children_ids = [record["child.id"] for record in children]
176+
children_ids.append("en:sweet yogurts")
177+
await taxonomy_test.update_node_children("en:yogurts", children_ids)
178+
background_tasks = FakeBackgroundTask()
179+
file_path = taxonomy_test.dump_taxonomy(background_tasks)
180+
result = list(open(file_path))
181+
# expected output
182+
expected = list(open("tests/data/test.txt"))
183+
# new entry inserted just after yogurts, the parent
184+
expected[16:16] = [
185+
"< en:yogurts\n",
186+
"en: sweet yogurts\n",
187+
"\n",
188+
]
189+
assert result == expected
190+
# clean files
191+
background_tasks.run()
192+
193+
170194
@pytest.mark.anyio
171195
async def test_add_new_entry_as_child(taxonomy_test):
172196
async with graph_db.TransactionCtx():

parser/openfoodfacts_taxonomy_parser/patcher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def get_all_nodes(self, project_label):
2323
MATCH (n:({project_label}|REMOVED_{project_label}))
2424
WHERE
2525
// no external node
26-
n.is_external = false
26+
(n.is_external = false OR n.is_external IS NULL)
2727
AND (
2828
// modified nodes
2929
((n:TEXT OR n:SYNONYMS OR n:STOPWORDS OR n:ENTRY) AND n.modified IS NOT NULL)

0 commit comments

Comments
 (0)