Skip to content

Commit

Permalink
Add function to refresh task count in tags
Browse files Browse the repository at this point in the history
  • Loading branch information
diegogangl committed Feb 19, 2024
1 parent b64046d commit d0245fc
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion GTG/core/datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import string

from GTG.core.tasks import TaskStore, Filter
from GTG.core.tags import TagStore
from GTG.core.tags import TagStore, Tag
from GTG.core.saved_searches import SavedSearchStore
from GTG.core import firstrun_tasks
from GTG.core.dates import Date
Expand Down Expand Up @@ -193,6 +193,25 @@ def print_info(self) -> None:
print(f'- Tasks: {self.tasks.count()}')


def refresh_task_for_tag(self, tag: Tag) -> None:
"""Refresh task counts for a tag."""

try:
tag.task_count_open = self.task_count['open'][tag.name]
except KeyError:
tag.task_count_open = 0

try:
tag.task_count_closed = self.task_count['closed'][tag.name]
except KeyError:
tag.task_count_closed = 0

try:
tag.task_count_actionable = self.task_count['actionable'][tag.name]
except KeyError:
tag.task_count_actionable = 0


def refresh_task_count(self) -> None:
"""Refresh task count dictionary."""

Expand Down

0 comments on commit d0245fc

Please sign in to comment.