]> apps.delaporte.us Git - matrix-goal-bot.git/blobdiff - matrix_goal_bot/db.py
Add clear command
[matrix-goal-bot.git] / matrix_goal_bot / db.py
index 83749a30626bdff5f832fda1d36fd0457ffb80af..eef5acedf2da4f59aa60c29f75e5a9ff45dc7cbf 100644 (file)
@@ -65,6 +65,13 @@ def pretty_print(goal, tasks):
     return results
 
 
     return results
 
 
+def _get_with_id(cls, item_id):
+    return select(cls).where(cls.id == item_id)
+
+def _get_with_name(cls, name):
+    return select(cls).where(func.lower(cls.name) == func.lower(name))
+
+
 class Data():
     def __init__(self, db_file=None):
         if not db_file:
 class Data():
     def __init__(self, db_file=None):
         if not db_file:
@@ -99,7 +106,7 @@ class Data():
             return pref.goal_id
 
 
             return pref.goal_id
 
 
-    def clear_list(self, goal_id, clear_all=False):
+    def clear(self, goal_id, clear_all=False):
         with Session(self.engine) as session:
             goal = session.exec(_get_with_id(Goal, goal_id)).first()
             for item in goal.tasks:
         with Session(self.engine) as session:
             goal = session.exec(_get_with_id(Goal, goal_id)).first()
             for item in goal.tasks: