From: Edward Delaporte Date: Tue, 5 May 2026 22:07:37 +0000 (-0500) Subject: WIP Wins X-Git-Url: https://apps.delaporte.us/gitweb/matrix-goal-bot.git/commitdiff_plain/303394a7dcea600b7f4e9db20a7056c8433eef75 WIP Wins --- diff --git a/matrix_goal_bot/bot.py b/matrix_goal_bot/bot.py index 310319f..d62d188 100644 --- a/matrix_goal_bot/bot.py +++ b/matrix_goal_bot/bot.py @@ -30,6 +30,7 @@ More commands: remove ID - remove a task by ID start GOAL_ID - un-put-off a goal (reverse of later) visionless - list goals with no set vision + wins - list recently completed goals ''' @@ -254,6 +255,18 @@ class GoalBot(): results.append(item) return results + if match.command('wins'): + items = self.data.wins() + results = ['# Wins'] + if not items: + results.append('-- No wins yet --') + + for item in items: + results.append(item) + return results + + + if match.command('set.vision'): goal_id = int(match.args()[1]) vision_id = int(match.args()[2]) 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 diff --git a/matrix_goal_bot/tasks.py b/matrix_goal_bot/tasks.py index 1bacd91..9784b42 100644 --- a/matrix_goal_bot/tasks.py +++ b/matrix_goal_bot/tasks.py @@ -97,3 +97,10 @@ def setup(c): results = Data().setup() print(results) + +@task +def wins(c): + results = Data().wins() + for line in results: + print(line) +