From: Edward Delaporte Date: Fri, 3 Apr 2026 18:10:52 +0000 (-0500) Subject: Update to indicate completed goals X-Git-Url: https://apps.delaporte.us/gitweb/matrix-goal-bot.git/commitdiff_plain/63ac7fdf6c0d6dc54d2631d9eee2151db1265660?ds=inline Update to indicate completed goals --- diff --git a/matrix_goal_bot/db.py b/matrix_goal_bot/db.py index 405893a..a478533 100644 --- a/matrix_goal_bot/db.py +++ b/matrix_goal_bot/db.py @@ -33,7 +33,11 @@ class Goal(SQLModel, table=True): tasks: list["Task"] = Relationship(back_populates="goal") vision: Vision = Relationship(back_populates="goals") def __str__(self): - return f'{self.name} (Goal {self.id})' + if not self.complete_date: + return f'{self.name} (Goal {self.id})' + else: + completed = self.complete_date.strftime(DATE_FORMAT) + return f'(Done {completed}) {self.name} (Goal {self.id})' class Task(SQLModel, table=True): id: int | None = Field(default=None, primary_key=True) @@ -92,7 +96,7 @@ class Data(): def get_done_goals(self): - '''List all goals''' + '''List completed goals''' with Session(self.engine) as session: cmd = select(Goal).where(Goal.complete_date != None) return session.exec(cmd).all() diff --git a/matrix_goal_bot/tasks.py b/matrix_goal_bot/tasks.py index e9eb7c5..440afb4 100644 --- a/matrix_goal_bot/tasks.py +++ b/matrix_goal_bot/tasks.py @@ -24,6 +24,13 @@ def list(c): for goal in goals: print(goal) + +@task +def list_done(c): + goals = Data().get_done_goals() + for goal in goals: + print(goal) + @task def print_goal(c, id): goal,tasks = Data().get_goal(id) diff --git a/tasks.py b/tasks.py index c344190..2132e51 100644 --- a/tasks.py +++ b/tasks.py @@ -2,4 +2,4 @@ from invoke import Collection from matrix_goal_bot import tasks ns = Collection() -ns.add_collection(tasks) +ns.add_collection(tasks, 'goals')