]> us-delaporte.pagekite.me Git - matrix-goal-bot.git/commitdiff
Update to indicate completed goals
authorEdward Delaporte <edward@delaporte.us>
Fri, 3 Apr 2026 18:10:52 +0000 (13:10 -0500)
committerEdward Delaporte <edward@delaporte.us>
Fri, 3 Apr 2026 18:10:52 +0000 (13:10 -0500)
matrix_goal_bot/db.py
matrix_goal_bot/tasks.py
tasks.py

index 405893a6c8b68abba3a356024112d36d15b2928d..a47853369c80ea65af5ad583fcc9ce29bb77b752 100644 (file)
@@ -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):
     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)
 
 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):
 
 
     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()
         with Session(self.engine) as session:
             cmd = select(Goal).where(Goal.complete_date != None)
             return session.exec(cmd).all()
index e9eb7c5e1f67acfde9880b04d4f47250f6b7cf35..440afb4790e9eae447ca2fa2c20e618c745e1c99 100644 (file)
@@ -24,6 +24,13 @@ def list(c):
     for goal in goals:
         print(goal)
 
     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)
 @task
 def print_goal(c, id):
     goal,tasks = Data().get_goal(id)
index c344190809ec877f770ad1773855bc03d87d6613..2132e5158cd849f3ab3b37be30376e2638ca6cf8 100644 (file)
--- a/tasks.py
+++ b/tasks.py
@@ -2,4 +2,4 @@ from invoke import Collection
 from matrix_goal_bot import tasks
 
 ns = Collection()
 from matrix_goal_bot import tasks
 
 ns = Collection()
-ns.add_collection(tasks)
+ns.add_collection(tasks, 'goals')