@@ -177,7 +177,7 @@ async def query_init(self, db: InfrahubDatabase, **kwargs):
177177 "from" : at .to_string (),
178178 }
179179
180- rel_prop_str = "{ branch: rel.branch, branch_level: rel.branch_level, status: rel.status, hierarchy: rel.hierarchical, from: $at, to: null }"
180+ rel_prop_str = "{ branch: rel.branch, branch_level: rel.branch_level, status: rel.status, hierarchy: rel.hierarchical, from: $at }"
181181
182182 iphost_prop = {
183183 "value" : "attr.content.value" ,
@@ -205,56 +205,56 @@ async def query_init(self, db: InfrahubDatabase, **kwargs):
205205 WITH distinct n
206206 FOREACH ( attr IN $attrs |
207207 CREATE (a:Attribute { uuid: attr.uuid, name: attr.name, branch_support: attr.branch_support })
208- CREATE (n)-[:HAS_ATTRIBUTE { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at, to: null }]->(a)
208+ CREATE (n)-[:HAS_ATTRIBUTE { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at }]->(a)
209209 MERGE (av:AttributeValue { value: attr.content.value, is_default: attr.content.is_default })
210- CREATE (a)-[:HAS_VALUE { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at, to: null }]->(av)
210+ CREATE (a)-[:HAS_VALUE { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at }]->(av)
211211 MERGE (ip:Boolean { value: attr.is_protected })
212212 MERGE (iv:Boolean { value: attr.is_visible })
213- CREATE (a)-[:IS_PROTECTED { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at, to: null }]->(ip)
214- CREATE (a)-[:IS_VISIBLE { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at, to: null }]->(iv)
213+ CREATE (a)-[:IS_PROTECTED { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at }]->(ip)
214+ CREATE (a)-[:IS_VISIBLE { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at }]->(iv)
215215 FOREACH ( prop IN attr.source_prop |
216216 MERGE (peer:Node { uuid: prop.peer_id })
217- CREATE (a)-[:HAS_SOURCE { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at, to: null }]->(peer)
217+ CREATE (a)-[:HAS_SOURCE { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at }]->(peer)
218218 )
219219 FOREACH ( prop IN attr.owner_prop |
220220 MERGE (peer:Node { uuid: prop.peer_id })
221- CREATE (a)-[:HAS_OWNER { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at, to: null }]->(peer)
221+ CREATE (a)-[:HAS_OWNER { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at }]->(peer)
222222 )
223223 )
224224 FOREACH ( attr IN $attrs_iphost |
225225 CREATE (a:Attribute { uuid: attr.uuid, name: attr.name, branch_support: attr.branch_support })
226- CREATE (n)-[:HAS_ATTRIBUTE { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at, to: null }]->(a)
226+ CREATE (n)-[:HAS_ATTRIBUTE { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at }]->(a)
227227 MERGE (av:AttributeValue:AttributeIPHost { %(iphost_prop)s })
228- CREATE (a)-[:HAS_VALUE { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at, to: null }]->(av)
228+ CREATE (a)-[:HAS_VALUE { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at }]->(av)
229229 MERGE (ip:Boolean { value: attr.is_protected })
230230 MERGE (iv:Boolean { value: attr.is_visible })
231- CREATE (a)-[:IS_PROTECTED { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at, to: null }]->(ip)
232- CREATE (a)-[:IS_VISIBLE { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at, to: null }]->(iv)
231+ CREATE (a)-[:IS_PROTECTED { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at }]->(ip)
232+ CREATE (a)-[:IS_VISIBLE { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at }]->(iv)
233233 FOREACH ( prop IN attr.source_prop |
234234 MERGE (peer:Node { uuid: prop.peer_id })
235- CREATE (a)-[:HAS_SOURCE { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at, to: null }]->(peer)
235+ CREATE (a)-[:HAS_SOURCE { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at }]->(peer)
236236 )
237237 FOREACH ( prop IN attr.owner_prop |
238238 MERGE (peer:Node { uuid: prop.peer_id })
239- CREATE (a)-[:HAS_OWNER { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at, to: null }]->(peer)
239+ CREATE (a)-[:HAS_OWNER { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at }]->(peer)
240240 )
241241 )
242242 FOREACH ( attr IN $attrs_ipnetwork |
243243 CREATE (a:Attribute { uuid: attr.uuid, name: attr.name, branch_support: attr.branch_support })
244- CREATE (n)-[:HAS_ATTRIBUTE { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at, to: null }]->(a)
244+ CREATE (n)-[:HAS_ATTRIBUTE { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at }]->(a)
245245 MERGE (av:AttributeValue:AttributeIPNetwork { %(ipnetwork_prop)s })
246- CREATE (a)-[:HAS_VALUE { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at, to: null }]->(av)
246+ CREATE (a)-[:HAS_VALUE { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at }]->(av)
247247 MERGE (ip:Boolean { value: attr.is_protected })
248248 MERGE (iv:Boolean { value: attr.is_visible })
249- CREATE (a)-[:IS_PROTECTED { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at, to: null }]->(ip)
250- CREATE (a)-[:IS_VISIBLE { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at, to: null }]->(iv)
249+ CREATE (a)-[:IS_PROTECTED { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at }]->(ip)
250+ CREATE (a)-[:IS_VISIBLE { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at }]->(iv)
251251 FOREACH ( prop IN attr.source_prop |
252252 MERGE (peer:Node { uuid: prop.peer_id })
253- CREATE (a)-[:HAS_SOURCE { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at, to: null }]->(peer)
253+ CREATE (a)-[:HAS_SOURCE { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at }]->(peer)
254254 )
255255 FOREACH ( prop IN attr.owner_prop |
256256 MERGE (peer:Node { uuid: prop.peer_id })
257- CREATE (a)-[:HAS_OWNER { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at, to: null }]->(peer)
257+ CREATE (a)-[:HAS_OWNER { branch: attr.branch, branch_level: attr.branch_level, status: attr.status, from: $at }]->(peer)
258258 )
259259 )
260260 FOREACH ( rel IN $rels_bidir |
@@ -264,15 +264,15 @@ async def query_init(self, db: InfrahubDatabase, **kwargs):
264264 CREATE (d)-[:IS_RELATED %(rel_prop)s ]->(rl)
265265 MERGE (ip:Boolean { value: rel.is_protected })
266266 MERGE (iv:Boolean { value: rel.is_visible })
267- CREATE (rl)-[:IS_PROTECTED { branch: rel.branch, branch_level: rel.branch_level, status: rel.status, from: $at, to: null }]->(ip)
268- CREATE (rl)-[:IS_VISIBLE { branch: rel.branch, branch_level: rel.branch_level, status: rel.status, from: $at, to: null }]->(iv)
267+ CREATE (rl)-[:IS_PROTECTED { branch: rel.branch, branch_level: rel.branch_level, status: rel.status, from: $at }]->(ip)
268+ CREATE (rl)-[:IS_VISIBLE { branch: rel.branch, branch_level: rel.branch_level, status: rel.status, from: $at }]->(iv)
269269 FOREACH ( prop IN rel.source_prop |
270270 MERGE (peer:Node { uuid: prop.peer_id })
271- CREATE (rl)-[:HAS_SOURCE { branch: rel.branch, branch_level: rel.branch_level, status: rel.status, from: $at, to: null }]->(peer)
271+ CREATE (rl)-[:HAS_SOURCE { branch: rel.branch, branch_level: rel.branch_level, status: rel.status, from: $at }]->(peer)
272272 )
273273 FOREACH ( prop IN rel.owner_prop |
274274 MERGE (peer:Node { uuid: prop.peer_id })
275- CREATE (rl)-[:HAS_OWNER { branch: rel.branch, branch_level: rel.branch_level, status: rel.status, from: $at, to: null }]->(peer)
275+ CREATE (rl)-[:HAS_OWNER { branch: rel.branch, branch_level: rel.branch_level, status: rel.status, from: $at }]->(peer)
276276 )
277277 )
278278 FOREACH ( rel IN $rels_out |
@@ -282,15 +282,15 @@ async def query_init(self, db: InfrahubDatabase, **kwargs):
282282 CREATE (d)<-[:IS_RELATED %(rel_prop)s ]-(rl)
283283 MERGE (ip:Boolean { value: rel.is_protected })
284284 MERGE (iv:Boolean { value: rel.is_visible })
285- CREATE (rl)-[:IS_PROTECTED { branch: rel.branch, branch_level: rel.branch_level, status: rel.status, from: $at, to: null }]->(ip)
286- CREATE (rl)-[:IS_VISIBLE { branch: rel.branch, branch_level: rel.branch_level, status: rel.status, from: $at, to: null }]->(iv)
285+ CREATE (rl)-[:IS_PROTECTED { branch: rel.branch, branch_level: rel.branch_level, status: rel.status, from: $at }]->(ip)
286+ CREATE (rl)-[:IS_VISIBLE { branch: rel.branch, branch_level: rel.branch_level, status: rel.status, from: $at }]->(iv)
287287 FOREACH ( prop IN rel.source_prop |
288288 MERGE (peer:Node { uuid: prop.peer_id })
289- CREATE (rl)-[:HAS_SOURCE { branch: rel.branch, branch_level: rel.branch_level, status: rel.status, from: $at, to: null }]->(peer)
289+ CREATE (rl)-[:HAS_SOURCE { branch: rel.branch, branch_level: rel.branch_level, status: rel.status, from: $at }]->(peer)
290290 )
291291 FOREACH ( prop IN rel.owner_prop |
292292 MERGE (peer:Node { uuid: prop.peer_id })
293- CREATE (rl)-[:HAS_OWNER { branch: rel.branch, branch_level: rel.branch_level, status: rel.status, from: $at, to: null }]->(peer)
293+ CREATE (rl)-[:HAS_OWNER { branch: rel.branch, branch_level: rel.branch_level, status: rel.status, from: $at }]->(peer)
294294 )
295295 )
296296 FOREACH ( rel IN $rels_in |
@@ -300,15 +300,15 @@ async def query_init(self, db: InfrahubDatabase, **kwargs):
300300 CREATE (d)-[:IS_RELATED %(rel_prop)s ]->(rl)
301301 MERGE (ip:Boolean { value: rel.is_protected })
302302 MERGE (iv:Boolean { value: rel.is_visible })
303- CREATE (rl)-[:IS_PROTECTED { branch: rel.branch, branch_level: rel.branch_level, status: rel.status, from: $at, to: null }]->(ip)
304- CREATE (rl)-[:IS_VISIBLE { branch: rel.branch, branch_level: rel.branch_level, status: rel.status, from: $at, to: null }]->(iv)
303+ CREATE (rl)-[:IS_PROTECTED { branch: rel.branch, branch_level: rel.branch_level, status: rel.status, from: $at }]->(ip)
304+ CREATE (rl)-[:IS_VISIBLE { branch: rel.branch, branch_level: rel.branch_level, status: rel.status, from: $at }]->(iv)
305305 FOREACH ( prop IN rel.source_prop |
306306 MERGE (peer:Node { uuid: prop.peer_id })
307- CREATE (rl)-[:HAS_SOURCE { branch: rel.branch, branch_level: rel.branch_level, status: rel.status, from: $at, to: null }]->(peer)
307+ CREATE (rl)-[:HAS_SOURCE { branch: rel.branch, branch_level: rel.branch_level, status: rel.status, from: $at }]->(peer)
308308 )
309309 FOREACH ( prop IN rel.owner_prop |
310310 MERGE (peer:Node { uuid: prop.peer_id })
311- CREATE (rl)-[:HAS_OWNER { branch: rel.branch, branch_level: rel.branch_level, status: rel.status, from: $at, to: null }]->(peer)
311+ CREATE (rl)-[:HAS_OWNER { branch: rel.branch, branch_level: rel.branch_level, status: rel.status, from: $at }]->(peer)
312312 )
313313 )
314314 WITH distinct n
@@ -1205,10 +1205,10 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: Any) -> None: # pyli
12051205 MATCH path = (n)%(filter)s(peer)
12061206 WHERE all(r IN relationships(path) WHERE (%(branch_filter)s))
12071207 WITH %(with_clause)s
1208- RETURN peer as peer1, path as path1, all(r IN relationships(path) WHERE (r.status = "active")) AS is_active
1208+ RETURN peer as peer1, all(r IN relationships(path) WHERE (r.status = "active")) AS is_active
12091209 ORDER BY branch_level DESC, froms[-1] DESC, froms[-2] DESC, is_active DESC
12101210 }
1211- WITH peer1 as peer, path1 as path, is_active
1211+ WITH peer1 as peer, is_active
12121212 """ % {"filter" : filter_str , "branch_filter" : branch_filter , "with_clause" : with_clause }
12131213
12141214 self .add_to_query (query )
0 commit comments