X-Git-Url: https://plomlompom.com/repos/foo.html?a=blobdiff_plain;f=plomtask%2Fdays.py;h=3abd76974107d379813a888a8f6f39b7c44afdc8;hb=a8a7b5d0a5007274539e528968c68fe9f25e422e;hp=17bb46329760beb078a6497d68bd7b0a39a05e3e;hpb=b16ae56b9c1a5bb799594fdd759a400d40488350;p=plomtask
diff --git a/plomtask/days.py b/plomtask/days.py
index 17bb463..3abd769 100644
--- a/plomtask/days.py
+++ b/plomtask/days.py
@@ -35,11 +35,16 @@ class Day:
return cls(row[0])
@classmethod
- def all(cls, db_conn: DatabaseConnection):
- """Return list of all Days in database."""
+ def all(cls, db_conn: DatabaseConnection,
+ date_range: tuple[str, str] = ('', '')):
+ """Return list of Days in database within date_range."""
+ start_date = date_range[0] if date_range[0] else '2024-01-01'
+ end_date = date_range[1] if date_range[1] else '2030-12-31'
days = []
- for row in db_conn.exec('SELECT * FROM days'):
+ sql = 'SELECT * FROM days WHERE date >= ? AND date <= ?'
+ for row in db_conn.exec(sql, (start_date, end_date)):
days += [cls.from_table_row(row)]
+ days.sort()
return days
@property