Skip to content

Commit

Permalink
Update task counts on status change
Browse files Browse the repository at this point in the history
  • Loading branch information
diegogangl committed Feb 19, 2024
1 parent d8e65d5 commit f336e44
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions GTG/core/tasks2.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,18 @@ def toggle_dismiss(self, propagated: bool = False) -> None:
def set_status(self, status: Status, propagated: bool = False) -> None:
"""Set status for task."""

if self.status == Status.ACTIVE:
for t in self.tags:
t.task_count_open -= 1

if self.is_actionable:
for t in self.tags:
t.task_count_actionable -= 1

else:
for t in self.tags:
t.task_count_closed -= 1

self.status = status
self.is_active = (status == Status.ACTIVE)

Expand All @@ -179,6 +191,19 @@ def set_status(self, status: Status, propagated: bool = False) -> None:

if self.parent and self.parent.status is not Status.ACTIVE:
self.parent.set_status(status, propagated=True)

if status == Status.ACTIVE:
for t in self.tags:
t.task_count_open += 1

if self.is_actionable:
for t in self.tags:
t.task_count_actionable += 1

else:
for t in self.tags:
t.task_count_closed += 1


for child in self.children:
child.set_status(status, propagated=True)
Expand Down

0 comments on commit f336e44

Please sign in to comment.