From: Edward Delaporte Date: Wed, 15 Apr 2026 17:08:48 +0000 (-0500) Subject: fixup X-Git-Url: https://apps.delaporte.us/gitweb/matrix-goal-bot.git/commitdiff_plain/418eb36e29d647190e80190c8c0b016f2ba7d2ab fixup --- diff --git a/matrix_goal_bot/db.py b/matrix_goal_bot/db.py index d7896e0..83749a3 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) @@ -87,6 +87,7 @@ class Data(): prefs = session.exec(select(PreferGoal)).all() for pref in prefs: session.delete(pref) + session.commit() pref = PreferGoal() pref.goal_id = goal_id session.add(pref) @@ -120,7 +121,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).where(Goal.start_date <= today()) + cmd = select(Goal).where(Goal.complete_date == None) return session.exec(cmd).all() def get_done_goals(self): diff --git a/matrix_goal_bot/tasks.py b/matrix_goal_bot/tasks.py index be2004f..c7ff4b2 100644 --- a/matrix_goal_bot/tasks.py +++ b/matrix_goal_bot/tasks.py @@ -1,6 +1,6 @@ from invoke import task -from .db import Data +from .db import Data, pretty_print @task def setup(c): @@ -25,8 +25,8 @@ def rename_goal(c, goal_id, name): @task -def add_task(c, goal_id, name): - result = Data().add_task(goal_id=goal_id, name=name) +def add_task(c, name): + result = Data().quick_add_task(name=name) print(result) @task @@ -38,6 +38,18 @@ def remove_task(c, goal_id, name): @task def list(c): + goals = Data().get_current_goals() + for goal in goals: + print(goal) + +@task +def later(c, goal_id): + result = Data().put_off_goal(goal_id) + print(result) + + +@task +def list_all(c): goals = Data().get_all_goals() for goal in goals: print(goal) @@ -57,15 +69,15 @@ def list_done(c): print(goal) @task -def print_goal(c, id): - goal,tasks = Data().get_goal(id) - print(f' ## {goal}') - for task in tasks: - if(task.complete_date): - print(f' - [x] {task}') - else: - print(f' - [ ] {task}') - - +def print_goal(c, goal_id): + goal, tasks = Data().get_goal(goal_id) + results = pretty_print(goal, tasks) + for line in results: + print(line) + +@task +def clear(c, goal_id): + results = Data().clear(goal_id) + print(results)