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)
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()
from matrix_goal_bot import tasks
ns = Collection()
-ns.add_collection(tasks)
+ns.add_collection(tasks, 'goals')