Skip to content
This repository has been archived by the owner on Aug 14, 2023. It is now read-only.

Commit

Permalink
Merge pull request itota#17 from roandbox/get_children-depth
Browse files Browse the repository at this point in the history
Put recursion depth check where it should be: around the database query.
  • Loading branch information
thenor57 authored Jan 16, 2017
2 parents 2dde228 + a97b1c8 commit 2fe5035
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tracsubtickets/web_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,17 @@ def _append_parent_links(self, req, data, ids):
def prepare_ticket(self, req, ticket, fields, actions):
pass

def get_children(self, parent_id):
def get_children(self, parent_id, depth=0):
children = {}

for parent, child in self.env.db_query("""
SELECT parent, child FROM subtickets WHERE parent=%s
""", (parent_id, )):
children[child] = None

for id in children:
children[id] = self.get_children(id)
if self.opt_recursion_depth > depth or self.opt_recursion_depth == -1:
for id in children:
children[id] = self.get_children(id, depth + 1)

return children

Expand Down

0 comments on commit 2fe5035

Please sign in to comment.