home · contact · privacy
Re-factor Day.todos code.
[plomtask] / plomtask / http.py
index 91db32601c24c91c49db75df4f9ca2b05fd9b944..230ed3f26c5d53398a27d87558a28abeb28ceff5 100644 (file)
@@ -205,12 +205,13 @@ class TaskHandler(BaseHTTPRequestHandler):
     def do_GET_day(self) -> dict[str, object]:
         """Show single Day of ?date=."""
         date = self._params.get_str('date', date_in_n_days(0))
+        day = Day.by_id(self.conn, date, create=True,
+                        init_empty_todo_list=True)
         make_type = self._params.get_str('make_type')
-        todays_todos = Todo.by_date(self.conn, date)
         conditions_present = []
         enablers_for = {}
         disablers_for = {}
-        for todo in todays_todos:
+        for todo in day.todos:
             for condition in todo.conditions + todo.blockers:
                 if condition not in conditions_present:
                     conditions_present += [condition]
@@ -222,9 +223,8 @@ class TaskHandler(BaseHTTPRequestHandler):
                                                     if condition in p.disables]
         seen_todos: set[int] = set()
         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': Todo.total_effort_at_date(self.conn, date),
+                     for t in day.todos if not t.parents]
+        return {'day': day,
                 'top_nodes': top_nodes,
                 'make_type': make_type,
                 'enablers_for': enablers_for,