From: Edward Delaporte Date: Wed, 15 Apr 2026 17:41:08 +0000 (-0500) Subject: Breaking change add start_date X-Git-Url: https://apps.delaporte.us/gitweb/matrix-goal-bot.git/commitdiff_plain/4e1a9fea349dbabc177afde73208434130c16d13 Breaking change add start_date --- diff --git a/matrix_goal_bot/db.py b/matrix_goal_bot/db.py index eef5ace..533b684 100644 --- a/matrix_goal_bot/db.py +++ b/matrix_goal_bot/db.py @@ -28,7 +28,7 @@ class PreferGoal(SQLModel, table=True): class Goal(SQLModel, table=True): id: int | None = Field(default=None, primary_key=True) name: str = Field(default=None, unique=True) - # start_date: dt | None = Field(default=today()) + start_date: dt | None = Field(default=today()) complete_date: dt | None = Field(default=None) vision_id: int | None = Field(default=None, foreign_key="vision.id") notes: str | None = Field(default=None) @@ -88,6 +88,12 @@ class Data(): SQLModel.metadata.create_all(self.engine) return 'Success' + def migrate(self): + with Session(self.engine) as session: + session.exec(text(''' alter table goal add start_date DATETIME; ''')) + session.commit() + return 'Success' + def _set_pref_goal_id(self, goal_id): with Session(self.engine) as session: @@ -128,8 +134,8 @@ class Data(): def get_current_goals(self): '''List current goals''' with Session(self.engine) as session: - # cmd = select(Goal).where(Goal.complete_date == None).where(Goal.start_date <= today()) - cmd = select(Goal).where(Goal.complete_date == None) + cmd = select(Goal).where(Goal.complete_date == None).where(Goal.start_date <= today()) + # cmd = select(Goal).where(Goal.complete_date == None) return session.exec(cmd).all() def get_done_goals(self): @@ -185,6 +191,19 @@ class Data(): session.commit() return vision_id + def start_goal(self, goal_id): + vision = None + with Session(self.engine) as session: + cmd = select(Goal).where(Goal.id == goal_id) + goal = session.exec(cmd).first() + goal.start_date = dt.today() + vision_id = goal.vision_id + session.commit() + if vision: + return (vision, vision.goals) + else: + return ('No Vision Assigned', []) + def rename_goal(self, goal_id, name): self._set_pref_goal_id(goal_id) diff --git a/matrix_goal_bot/tasks.py b/matrix_goal_bot/tasks.py index a957f37..4fd4ce5 100644 --- a/matrix_goal_bot/tasks.py +++ b/matrix_goal_bot/tasks.py @@ -81,9 +81,20 @@ def print_goal(c, goal_id): for line in results: print(line) +@task +def start(c, goal_id): + vision, goals = Data().start_goal(goal_id) + results = pretty_print(vision, goals) + for line in results: + print(line) + @task def clear(c, goal_id): results = Data().clear(goal_id) print(results) +@task +def setup(c): + results = Data().setup() + print(results) diff --git a/pyproject.toml b/pyproject.toml index ff31aa1..5f1ae46 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = 'matrix-goal-bot' -version = '1.0.0' +version = '1.2.0' authors = [ {name = "Edward Delaporte", email = "edward@delaporte.us"}, ]