]> us-delaporte.pagekite.me Git - matrix-chore-bot.git/blobdiff - matrix_chore_bot/db.py
Allow space separated done list
[matrix-chore-bot.git] / matrix_chore_bot / db.py
index 315d2793682a5d8210d944c8f35bbe8bac0249ca..140f0a682b8ad4c99b530e4e66655df9bd63f6ce 100644 (file)
@@ -13,6 +13,8 @@ DATE_FORMAT = '%Y-%m-%d'
 def today():
     return dt.now().strftime(DATE_FORMAT)
 
+DEFAULT_DB_FILE = os.path.join(os.environ.get('MATRIX_DATA_DIR', ''), 'chores.db')
+DB_FILE = os.environ.get('MATRIX_CHORE_DB_FILE', DEFAULT_DB_FILE)
 
 logger = logging.getLogger(__name__)
 logging.basicConfig(filename='chore.log', encoding='utf-8', level=logging.DEBUG)
@@ -39,7 +41,7 @@ class Data():
     def __init__(self, db_file=None):
 
         if not db_file:
-            db_file = os.path.join(os.environ.get('MATRIX_DATA_DIR'), 'chores.db')
+            db_file = DB_FILE
 
         self.file = db_file
         self.engine = self.get_engine()
@@ -86,12 +88,23 @@ class Data():
             cmd = select(Chore)
             chores = session.exec(cmd).all()
             if(not chores):
-                retuls.append('None Found')
+                results.append('None Found')
 
             for chore in chores:
                 results.append(Data.check_chore(session, chore.id))
         return results
 
+    def filter(self, term):
+        results = []
+        for item in self.list():
+            if term in item:
+                results.append(item)
+
+        return results
+        
+
+
+
     def add(self, name):
         try:
             with Session(self.engine) as session: