Skip to content

Commit

Permalink
Additional clean of CYPHER query
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasG0 committed Feb 25, 2025
1 parent fb541fc commit 0783099
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions backend/infrahub/core/migrations/query/node_duplicate.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,10 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: dict[str, Any]) -> No
%(sub_query_in)s
}
WITH p2 as peer_node, rel_inband, active_node, new_node
FOREACH (i in CASE WHEN rel_inband.branch = "-global-" or rel_inband.branch = $branch THEN [1] ELSE [] END |
FOREACH (i in CASE WHEN rel_inband.branch IN ["-global-", $branch] THEN [1] ELSE [] END |
SET rel_inband.to = $current_time
)
WITH peer_node, rel_inband, active_node, new_node
RETURN DISTINCT new_node
""" % {
"branch_filter": branch_filter,
Expand Down
6 changes: 3 additions & 3 deletions backend/infrahub/core/migrations/schema/node_remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ def render_node_remove_query(self, branch_filter: str) -> str:
LIMIT 1
}
WITH n1 as active_node, rel_inband1 as rel_inband, p1 as peer_node
WHERE rel_inband.status = "active" AND rel_inband.to IS NULL
WHERE rel_inband.status = "active"
CALL {
%(sub_query)s
}
WITH p2 as peer_node, rel_inband, active_node
FOREACH (i in CASE WHEN rel_inband.branch = "-global-" or rel_inband.branch = $branch THEN [1] ELSE [] END |
FOREACH (i in CASE WHEN rel_inband.branch IN ["-global-", $branch] THEN [1] ELSE [] END |
SET rel_inband.to = $current_time
)
""" % {"sub_query": sub_query, "branch_filter": branch_filter}
Expand Down Expand Up @@ -151,7 +151,7 @@ def render_node_remove_query(self, branch_filter: str) -> str:
LIMIT 1
}
WITH n1 as active_node, rel_outband1 as rel_outband, p1 as peer_node
WHERE rel_outband.status = "active" AND rel_outband.to IS NULL
WHERE rel_outband.status = "active"
CALL {
%(sub_query)s
}
Expand Down

0 comments on commit 0783099

Please sign in to comment.