Skip to content

Commit

Permalink
Add incomplete_tasks and improve printing of projects
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreyMarkinPPC committed Mar 27, 2024
1 parent faa0245 commit 3b09ded
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
26 changes: 12 additions & 14 deletions terka/domain/entities/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from .entity import Entity
from .task import Task


class ProjectStatus(Enum):
DELETED = 0
ACTIVE = 1
Expand Down Expand Up @@ -105,26 +106,23 @@ def deleted(self):

@property
def backlog_tasks(self) -> list[Task]:
tasks = []
for task in self.tasks:
if task.status.name == "BACKLOG":
tasks.append(task)
return tasks
return self._get_tasks_by_statuses(("BACKLOG"))

@property
def open_tasks(self) -> list[Task]:
tasks = []
for task in self.tasks:
if task.status.name in ("TODO", "IN_PROGRESS", "REVIEW"):
tasks.append(task)
return tasks
return self._get_tasks_by_statuses(("TODO", "IN_PROGRESS", "REVIEW"))

@property
def completed_tasks(self) -> list[Task]:
return [
task for task in self.tasks
if task.status.name in ("DONE", "DELETED")
]
return self._get_tasks_by_statuses(("DONE", "DELETED"))

@property
def incompleted_tasks(self) -> list[Task]:
return self._get_tasks_by_statuses(
("BACKLOG", "TODO", "IN_PROGRESS", "REVIEW"))

def _get_tasks_by_statuses(self, statuses: tuple[str]) -> list[Task]:
return [task for task in self.tasks if task.status.name in statuses]

def daily_time_entries_hours(
self,
Expand Down
11 changes: 5 additions & 6 deletions terka/presentations/console/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,8 @@ def print_project(self, entities, print_options, kwargs=None):
reverse = False
entities.sort(key=sort_fn, reverse=reverse)
for entity in entities:
if len(open_tasks :=
entity.open_tasks) > 0 and entity.status.name == 'ACTIVE':

if len(incompleted_tasks := entity.incompleted_tasks
) > 0 and entity.status.name == "ACTIVE":
if overdue_tasks := entity.overdue_tasks:
entity_id = f'[red]{entity.id}[/red]'
else:
Expand All @@ -237,9 +236,9 @@ def print_project(self, entities, print_options, kwargs=None):
entity.description,
'status':
entity.status.name,
'open_tasks':
str(len(open_tasks)),
'overdue':
"open_tasks":
str(len(incompleted_tasks)),
"overdue":
str(len(overdue_tasks)),
'stale':
str(len(entity.stale_tasks)),
Expand Down

0 comments on commit 3b09ded

Please sign in to comment.