From: Edward Delaporte Date: Wed, 15 Apr 2026 17:11:49 +0000 (-0500) Subject: Add clear command X-Git-Url: https://apps.delaporte.us/gitweb/matrix-goal-bot.git/commitdiff_plain/41cec29a738f15fd16ef4f1b6f52cbd399ebf721?ds=sidebyside Add clear command --- 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: diff --git a/matrix_goal_bot/tasks.py b/matrix_goal_bot/tasks.py index c7ff4b2..a957f37 100644 --- a/matrix_goal_bot/tasks.py +++ b/matrix_goal_bot/tasks.py @@ -29,6 +29,12 @@ def add_task(c, name): result = Data().quick_add_task(name=name) print(result) + +@task +def done(c, task_id): + result = Data().complete_task(int(task_id)) + print(result) + @task def remove_task(c, goal_id, name): result = Data().add_task(goal_id=goal_id, name=name)