class Todo(BaseModel[int], ConditionsRelations):
"""Individual actionable."""
# pylint: disable=too-many-instance-attributes
+ # pylint: disable=too-many-public-methods
table_name = 'todos'
to_save = ['process_id', 'is_done', 'date', 'comment', 'effort',
'calendarize']
"""Collect all Todos for Day of date."""
return cls.by_date_range(db_conn, (date, date))
+ @classmethod
+ def total_effort_at_date(cls, db_conn: DatabaseConnection, date: str
+ ) -> float:
+ """Sum all .performed_effort of Todos at Day of date."""
+ total_effort = 0.0
+ days_todos = cls.by_date(db_conn, date)
+ for todo in days_todos:
+ total_effort += todo.performed_effort
+ return total_effort
+
@property
def is_doable(self) -> bool:
"""Decide whether .is_done settable based on children, Conditions."""
"""Return sum of performed efforts of self and all descendants."""
def walk_tree(node: Todo) -> float:
- local_effort = 0
+ local_effort = 0.0
for child in node.children:
local_effort += walk_tree(child)
return node.performed_effort + local_effort