home · contact · privacy
Fix bug of /day POSTS breaking on empty new_todo fields.
[plomtask] / plomtask / days.py
index 18c9769f5aec59863715969c3a6b8bd5e102ec3d..3d9d04182e740d843ffe4c7ec98c68abd6c3a93d 100644 (file)
@@ -50,20 +50,15 @@ class Day(BaseModel[str]):
             day.todos = Todo.by_date(db_conn, day.id_)
         return day
 
-    @classmethod
-    def by_date_range_filled(cls, db_conn: DatabaseConnection,
-                             start: str, end: str) -> list[Day]:
-        """Return days existing and non-existing between dates start/end."""
-        ret = cls.by_date_range_with_limits(db_conn, (start, end), 'id')
-        days, start_date, end_date = ret
-        return cls.with_filled_gaps(days, start_date, end_date)
-
     @classmethod
     def with_filled_gaps(cls, days: list[Day], start_date: str, end_date: str
                          ) -> list[Day]:
-        """In days, fill with (un-saved) Days gaps between start/end_date."""
+        """In days, fill with (un-stored) Days gaps between start/end_date."""
+        days = days[:]
+        start_date, end_date = valid_date(start_date), valid_date(end_date)
         if start_date > end_date:
-            return days
+            return []
+        days = [d for d in days if d.date >= start_date and d.date <= end_date]
         days.sort()
         if start_date not in [d.date for d in days]:
             days[:] = [Day(start_date)] + days