def walk_process_steps(node_id: int,
process_step_nodes: list[ProcessStepsNode],
- steps_nodes: list[TodoStepsNode]) -> None:
+ steps_nodes: list[TodoStepsNode]) -> int:
for process_step_node in process_step_nodes:
node_id += 1
node = TodoStepsNode(node_id, None, process_step_node.process,
[])
steps_nodes += [node]
- walk_process_steps(node_id,
- list(process_step_node.steps.values()),
- node.children)
+ node_id = walk_process_steps(
+ node_id, list(process_step_node.steps.values()),
+ node.children)
+ return node_id
def walk_todo_steps(node_id: int, todos: list[Todo],
- steps_nodes: list[TodoStepsNode]) -> None:
+ steps_nodes: list[TodoStepsNode]) -> int:
for todo in todos:
matched = False
for match in [item for item in steps_nodes
matched = True
for child in match.children:
child.fillable = True
- walk_todo_steps(node_id, todo.children, match.children)
+ node_id = walk_todo_steps(
+ node_id, todo.children, match.children)
if not matched:
node_id += 1
node = TodoStepsNode(node_id, todo, None, [])
steps_nodes += [node]
- walk_todo_steps(node_id, todo.children, node.children)
+ node_id = walk_todo_steps(
+ node_id, todo.children, node.children)
+ return node_id
- def collect_adoptables_keys(steps_nodes: list[TodoStepsNode]
- ) -> set[int]:
+ def collect_adoptables_keys(
+ steps_nodes: list[TodoStepsNode]) -> set[int]:
ids = set()
for node in steps_nodes:
if not node.todo:
todo_steps = [step.todo for step in todo.get_step_tree(set()).children]
process_tree = todo.process.get_steps(self.conn, None)
steps_todo_to_process: list[TodoStepsNode] = []
- walk_process_steps(0, list(process_tree.values()),
- steps_todo_to_process)
+ last_node_id = walk_process_steps(
+ 0, list(process_tree.values()), steps_todo_to_process)
for steps_node in steps_todo_to_process:
steps_node.fillable = True
- walk_todo_steps(len(steps_todo_to_process), todo_steps,
- steps_todo_to_process)
+ walk_todo_steps(last_node_id, todo_steps, steps_todo_to_process)
adoptables: dict[int, list[Todo]] = {}
any_adoptables = [Todo.by_id(self.conn, t.id_)
for t in Todo.by_date(self.conn, todo.date)
for id_ in collect_adoptables_keys(steps_todo_to_process):
adoptables[id_] = [t for t in any_adoptables
if t.process.id_ == id_]
- return {'todo': todo, 'steps_todo_to_process': steps_todo_to_process,
+ return {'todo': todo,
+ 'steps_todo_to_process': steps_todo_to_process,
'adoption_candidates_for': adoptables,
'process_candidates': Process.all(self.conn),
'todo_candidates': any_adoptables,