]> apps.delaporte.us Git - matrix-chore-bot.git/commitdiff
Add invoke debug task to check db
authorEdward Delaporte <edward@delaporte.us>
Tue, 7 Apr 2026 01:01:03 +0000 (20:01 -0500)
committerEdward Delaporte <edward@delaporte.us>
Tue, 7 Apr 2026 01:01:03 +0000 (20:01 -0500)
matrix_chore_bot/db.py
matrix_chore_bot/tasks.py

index 1a07bec5af581eae1c1f12d5be2420265443ac5c..a0eae22f210f4374073a8ae41fa8c43a3053b57f 100644 (file)
@@ -35,14 +35,14 @@ def get_chore(session, chore_id):
     return session.exec(cmd).first()
 
 class Data():
-    def __init__(self, db_file=None):
-
-        if not db_file:
-            db_file = DB_FILE
+    def __init__(self, db_file):
 
         self.file = db_file
         self.engine = self.get_engine()
 
+    def get_db_file(self):
+        return self.file
+
     def get_engine(self):
         return create_engine(f"sqlite:///{self.file}")
 
index 5a4eaa6dadfa183cb28b81872912007f8266ac1e..f95400b6ef15ce35e39c54553c3c3ec95c6cb9cd 100644 (file)
@@ -1,42 +1,55 @@
+import os
+
 from invoke import task
 
 from .db import Data
 
+
+# Where to store data
+DATA_DIR = os.environ.get('MATRIX_DATA_DIR', '')
+DB_FILE = os.environ.get('MATRIX_DB_FILE', 'chore.db')
+db_file = os.path.join(DATA_DIR, DB_FILE)
+
+DATA = Data(db_file)
+
 @task
 def add(c, task):
-    result = Data().add(task)
+    result = DATA.add(task)
     print(result)
 
 
 @task
 def check(c, task):
-    result = Data().check(task)
+    result = DATA.check(task)
     print(result)
 
 @task
 def done(c, task):
-    result = Data().done(task)
+    result = DATA.done(task)
     print(result)
 
 @task
 def undo(c, task):
-    result = Data().undo(task)
+    result = DATA.undo(task)
     print(result)
 
 @task
 def remove(c, task):
-    result = Data().remove(task)
+    result = DATA.remove(task)
     print(result)
 
 @task
 def list(c):
-    result = Data().list()
+    result = DATA.list()
     for item in result:
         print(f'{item}')
 
 @task
 def filter(c, term):
-    result = Data().filter(term)
+    result = DATA.filter(term)
     for item in result:
         print(f'{item}')
 
+@task
+def debug(c):
+    print(DATA.get_db_file())