Skip to content

Commit

Permalink
Moved edge-related methods in Node to the end for better organization
Browse files Browse the repository at this point in the history
  • Loading branch information
JackAtOmenApps committed Nov 22, 2020
1 parent 386423b commit bbf12ca
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions django_postgresql_dag/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,34 @@ def leaves(self):
leaves.add(self)
return leaves

def descendants_edges(self):
"""
Returns a queryset of descendants edges
ToDo: Perform topological sort
"""
return edge_model.objects.filter(
parent__in=self.self_and_descendants(),
child__in=self.self_and_descendants(),
)

def ancestors_edges(self):
"""
Returns a queryset of ancestors edges
ToDo: Perform topological sort
"""
return edge_model.objects.filter(
parent__in=self.self_and_ancestors(),
child__in=self.self_and_ancestors(),
)

def clan_edges(self):
"""
Returns a queryset of all edges associated with a given node
"""
return self.ancestors_edges() | self.descendants_edges()

@staticmethod
def circular_checker(parent, child):
if child in parent.self_and_ancestors():
Expand Down

0 comments on commit bbf12ca

Please sign in to comment.