X-Git-Url: https://us-delaporte.pagekite.me/gitweb/matrix-goal-bot.git/blobdiff_plain/0903eca055e730402afc1f8d1315308dc08212ae..303394a7dcea600b7f4e9db20a7056c8433eef75:/matrix_goal_bot/db.py diff --git a/matrix_goal_bot/db.py b/matrix_goal_bot/db.py index 1d80aaa..fa3f082 100644 --- a/matrix_goal_bot/db.py +++ b/matrix_goal_bot/db.py @@ -42,6 +42,7 @@ class Goal(SQLModel, table=True): 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) name: str = Field(default=None, unique=True) @@ -52,6 +53,15 @@ class Task(SQLModel, table=True): return f'{self.name} ({self.id})' +class Win(SQLModel, table=True): + id: int | None = Field(default=None, primary_key=True) + goal: str = Field(default=None, unique=False) + vision: str = Field(default=None, unique=False) + complete_date: dt | None = Field(default=dt.today()) + def __str__(self): + completed = self.complete_date.strftime(DATE_FORMAT) + return f'{self.goal} ({completed} {vision})' + def pretty_print(goal, tasks): results = [] results.append(f' ## {goal}') @@ -179,6 +189,16 @@ class Data(): goal = session.exec(cmd).first() goal.complete_date = dt.today() vision_id = goal.vision_id + + cmd = select(Vision).where(Vision.id == vision_id) + win = Win() + win.goal = goal.name + + vision = session.exec(cmd).first() + if vision: + win.vision = vision.name + + session.add(win) session.commit() return vision_id @@ -291,5 +311,12 @@ class Data(): '''Notes print with the goal.''' pass + + def wins(self): + results = [] + with Session(self.engine) as session: + results = session.exec(select(Win)).all() + return results + # Someday: Notes on each