Skip to main content

compute_nested_progress

Function compute_nested_progress 

Source
pub fn compute_nested_progress(
    conn: &Connection,
    goal_id: &str,
) -> Result<GoalProgress, HierarchyError>
Expand description

Compute the nested progress of a goal, rolling up through the entire subtree.

For a goal hierarchy like:

Goal A
  ├── Task X (done)
  ├── Goal B
  │   ├── Task Y (done)
  │   └── Task Z (open)
  └── Task W (doing)

The nested progress for Goal A counts leaf items (tasks) across the whole tree: done=2, in_progress=1, total=4.

Intermediate goal nodes themselves are not counted as progress items — only their leaf children are. This means a goal with no children contributes zero to the total.

§Errors

Returns HierarchyError::ItemNotFound if goal_id does not exist, HierarchyError::NotAGoal if the item is not of kind goal, or HierarchyError::Db for database failures.