From: Edward Delaporte Date: Tue, 24 Mar 2026 04:20:13 +0000 (-0500) Subject: Add ability to list complete goals X-Git-Url: https://apps.delaporte.us/gitweb/matrix-goal-bot.git/commitdiff_plain/f35e5f517d4e17c1de54bc2a9a0faa7e77d841b2?ds=sidebyside Add ability to list complete goals --- diff --git a/bot.py b/bot.py index efc56a5..3cba5cf 100644 --- a/bot.py +++ b/bot.py @@ -37,6 +37,7 @@ async def do_goal(match): add-task ID - add a task under the goal specified by ID list - list incomplete goals list-all - list everything + list-done - list completed goals print ID - print a goal and all tasks print-vision ID - print a vision and all goals done ID - mark task done by ID @@ -59,11 +60,20 @@ async def do_goal(match): if match.command('list'): goals = Data().get_all_goals() - results = ['Goals list...'] + results = ['# Goals list...'] for goal in goals: results.append(str(goal)) return results + + if match.command('list-done'): + goals = Data().get_done_goals() + results = ['# Completed Goals...'] + for goal in goals: + results.append(str(goal)) + return results + + if match.command('add-task'): goal_id = int(match.args()[1]) new = ' '.join(match.args()[2:]) diff --git a/goals/db.py b/goals/db.py index 6e53948..11b5467 100644 --- a/goals/db.py +++ b/goals/db.py @@ -92,6 +92,13 @@ class Data(): return session.exec(cmd).all() + def get_done_goals(self): + '''List all goals''' + with Session(self.engine) as session: + cmd = select(Goal).where(Goal.complete_date != None) + return session.exec(cmd).all() + + def get_goal(self, id): with Session(self.engine) as session: cmd = select(Goal).where(Goal.id == id)