]> apps.delaporte.us Git - matrix-goal-bot.git/commitdiff
Breaking change add start_date
authorEdward Delaporte <edward@delaporte.us>
Wed, 15 Apr 2026 17:41:08 +0000 (12:41 -0500)
committerEdward Delaporte <edward@delaporte.us>
Wed, 15 Apr 2026 17:41:08 +0000 (12:41 -0500)
matrix_goal_bot/db.py
matrix_goal_bot/tasks.py
pyproject.toml

index eef5acedf2da4f59aa60c29f75e5a9ff45dc7cbf..533b6840b091617bc5702d51ec464d4c8d6600bd 100644 (file)
@@ -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)
index a957f37568d4eceb07dee1e3fb8db8054d00f101..4fd4ce5d30200a42d75f47e31382ec0600f0f9eb 100644 (file)
@@ -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)
 
index ff31aa19f09d28f903e6ba8ea26c8df459d79e94..5f1ae46a8c32238b30084832622c3cf89a53cd87 100644 (file)
@@ -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"},
 ]