X-Git-Url: https://us-delaporte.pagekite.me/gitweb/matrix-goal-bot.git/blobdiff_plain/418eb36e29d647190e80190c8c0b016f2ba7d2ab..41cec29a738f15fd16ef4f1b6f52cbd399ebf721:/matrix_goal_bot/db.py diff --git a/matrix_goal_bot/db.py b/matrix_goal_bot/db.py index 83749a3..eef5ace 100644 --- a/matrix_goal_bot/db.py +++ b/matrix_goal_bot/db.py @@ -65,6 +65,13 @@ def pretty_print(goal, tasks): 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: @@ -99,7 +106,7 @@ class Data(): 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: