]> apps.delaporte.us Git - matrix-goal-bot.git/blobdiff - matrix_goal_bot/db.py
Add visionless command
[matrix-goal-bot.git] / matrix_goal_bot / db.py
index 4c2d4775ca5dd0094ac15cf519c146069bba79eb..97ea2c05b623038dffefdc2d6e36999a78f3fccc 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):
-        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()
@@ -173,21 +177,16 @@ class Data():
             goal.vision_id = vision_id
             session.commit()
 
+    def visionless(self):
+        '''Get goals with no vision'''
+        with Session(self.engine) as session:
+            cmd = select(Goal).where(Goal.vision_id  == None)
+            return session.exec(cmd).all()
+
+
     def add_note(self, note, goal):
         '''Notes print with the goal.'''
         pass
 
     # Someday: Notes on each
 
-    def list(self):
-        results = []
-        with Session(self.engine) as session:
-            cmd = select(Chore)
-            chores = session.exec(cmd).all()
-            if(not chores):
-                retuls.append('None Found')
-
-            for chore in chores:
-                results.append(Data.check_chore(session, chore.id))
-        return results
-