"""Show single Day of ?date=."""
date = self.params.get_str('date', date_in_n_days(0))
todays_todos = Todo.by_date(self.conn, date)
+ total_effort = 0
+ for todo in todays_todos:
+ total_effort += todo.performed_effort
conditions_present = []
enablers_for = {}
disablers_for = {}
top_nodes = [t.get_step_tree(seen_todos)
for t in todays_todos if not t.parents]
return {'day': Day.by_id(self.conn, date, create=True),
+ 'total_effort': total_effort,
'top_nodes': top_nodes,
'enablers_for': enablers_for,
'disablers_for': disablers_for,
return False
return True
+ @property
+ def performed_effort(self) -> float:
+ """Return performed effort, i.e. self.effort or default if done.."""
+ if self.effort is not None:
+ return self.effort
+ if self.is_done:
+ return self.effort_then
+ return 0
+
@property
def process_id(self) -> int | str | None:
"""Needed for super().save to save Processes as attributes."""
return make_node(self)
+ @property
+ def tree_effort(self) -> float:
+ """Return sum of performed efforts of self and all descendants."""
+
+ def walk_tree(node: Todo) -> float:
+ local_effort = 0
+ for child in node.children:
+ local_effort += walk_tree(child)
+ return node.performed_effort + local_effort
+
+ return walk_tree(self)
+
def add_child(self, child: Todo) -> None:
"""Add child to self.children, avoid recursion, update parenthoods."""
{% macro show_node_done(node, indent, path) %}
{% if node.todo.has_doneness_in_path %}
<tr{% if not node.todo.is_done %} class="hidden_undone"{% endif %}>
+<td>{{node.todo.performed_effort}}</td>
+<td>{{node.todo.tree_effort|round(1)}}</td>
<td>
{% for i in range(indent) %} {% endfor %} +
{% if not node.todo.is_done %}({% endif %}<a href="todo?id={{node.todo.id_}}">{{node.todo.title_then|e}}</a>{% if not node.todo.is_done %}){% endif %}
</td>
<td>{{node.todo.comment|e}}</td>
</tr>
-
{% if not node.seen %}
{% for child in node.children %}
{{ show_node_done(child, indent+1) }}
{% block content %}
-<h3>{{day.date}} / {{day.weekday}}</h3>
+<h3>{{day.date}} / {{day.weekday}} ({{total_effort|round(1)}})</h3>
<p>
<a href="day?date={{day.prev_date}}">prev</a> | <a href="day?date={{day.next_date}}">next</a>
</p>