X-Git-Url: https://us-delaporte.pagekite.me/gitweb/matrix-goal-bot.git/blobdiff_plain/f6957376c90b1931bed792024ec6bd914b7d4546..3fbc817001f4e0bd0590b2bf3509e4bfc286919f:/goals/db.py?ds=sidebyside diff --git a/goals/db.py b/goals/db.py index 84369e2..0a1d16c 100644 --- a/goals/db.py +++ b/goals/db.py @@ -66,7 +66,10 @@ class Data(): def list_goals(self): '''List all goals''' - pass + with Session(self.engine) as session: + cmd = select(Goal).where(Goal.complete_date == None) + return session.exec(cmd).all() + def print_goal(self, id, include_finished=False): '''Includes tasks''' @@ -96,10 +99,11 @@ class Data(): def add_goal(self, name): return self.add_with_name(Goal, name) - def add_task(self, name, goal_id): + def add_task(self, goal_id, name): result = self.add_with_name(Task, name) with Session(self.engine) as session: - new = select(Task).where(Task.name == name).first() + cmd = select(Task).where(Task.name == name) + new = session.exec(cmd).first() new.goal_id = goal_id session.commit() return result @@ -107,7 +111,8 @@ class Data(): def assign_vision(self, goal_id, vision_id): '''Goals may move between visions''' with Session(self.engine) as session: - new = select(Goal).where(Goal.id == goal_id).first() + cmd = select(Goal).where(Goal.id == goal_id) + new = session.exec(cmd).first() new.vision_id = vision_id session.commit()