Skip to content

Commit e530675

Browse files
Preliminary implementation of filters for path search
1 parent c3040ef commit e530675

File tree

1 file changed

+39
-14
lines changed

1 file changed

+39
-14
lines changed

django_postgresql_dag/models.py

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -506,33 +506,58 @@ def path_ids_list(
506506
if self == target_node:
507507
return [[self.id]]
508508

509+
510+
downward_clauses, upward_clauses = ("", "")
511+
query_parameters = {
512+
"starting_node": self.id,
513+
"ending_node": target_node.id,
514+
"max_depth": max_depth,
515+
"max_paths": max_paths,
516+
}
517+
518+
limiting_fk_nodes_instance = kwargs.get("limiting_fk_nodes_instance", None)
519+
limiting_fk_edges_instance = kwargs.get("limiting_fk_edges_instance", None)
520+
excluded_nodes_queryset = kwargs.get("excluded_nodes_queryset", None)
521+
excluded_edges_queryset = kwargs.get("excluded_edges_queryset", None)
522+
required_nodes_queryset = kwargs.get("required_nodes_queryset", None)
523+
required_edges_queryset = kwargs.get("required_edges_queryset", None)
524+
525+
if limiting_fk_nodes_instance is not None:
526+
pass # Not implemented yet
527+
528+
if limiting_fk_edges_instance is not None:
529+
pass # Not implemented yet
530+
531+
if excluded_nodes_queryset is not None:
532+
pass # Not implemented yet
533+
534+
if excluded_edges_queryset is not None:
535+
pass # Not implemented yet
536+
537+
if required_nodes_queryset is not None:
538+
pass # Not implemented yet
539+
540+
if required_edges_queryset is not None:
541+
pass # Not implemented yet
542+
543+
509544
with connection.cursor() as cursor:
510545
cursor.execute(
511546
DOWNWARD_PATH_QUERY.format(
512547
relationship_table=edge_model_table,
513-
# downward_clauses=downward_clauses
548+
downward_clauses=downward_clauses
514549
),
515-
{
516-
"starting_node": self.id,
517-
"ending_node": target_node.id,
518-
"max_depth": max_depth,
519-
"max_paths": max_paths,
520-
},
550+
query_parameters
521551
)
522552
path = [row[0] + [target_node.id] for row in cursor.fetchall()]
523553
if not path and not directional:
524554
with connection.cursor() as cursor:
525555
cursor.execute(
526556
UPWARD_PATH_QUERY.format(
527557
relationship_table=edge_model_table,
528-
# upward_clauses=upward_clauses
558+
upward_clauses=upward_clauses
529559
),
530-
{
531-
"starting_node": self.id,
532-
"ending_node": target_node.id,
533-
"max_depth": max_depth,
534-
"max_paths": max_paths,
535-
},
560+
query_parameters
536561
)
537562
path = [
538563
[target_node.id] + row[0][::-1] for row in cursor.fetchall()

0 commit comments

Comments
 (0)