aboutsummaryrefslogtreecommitdiff
path: root/src/db/tasks.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/db/tasks.py')
-rw-r--r--src/db/tasks.py25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/db/tasks.py b/src/db/tasks.py
index 142abae..dca7710 100644
--- a/src/db/tasks.py
+++ b/src/db/tasks.py
@@ -3,8 +3,10 @@ import time
from typing import List
from model.task import Task, ValidTaskForm
+from model.status import Status
+from model import difficulty, priority, status
-def get(cursor: Cursor) -> List[Task]:
+def get(cursor: Cursor, s: Status) -> List[Task]:
cursor.execute(
" SELECT"
" id,"
@@ -15,7 +17,11 @@ def get(cursor: Cursor) -> List[Task]:
" difficulty,"
" priority,"
" description"
- " FROM tasks")
+ " FROM"
+ " tasks"
+ " WHERE"
+ " status = ?",
+ (status.format(s),))
res = []
@@ -26,14 +32,14 @@ def get(cursor: Cursor) -> List[Task]:
updated_at = task[2],
name = task[3],
duration = task[4],
- difficulty = task[5],
- priority = task[6],
+ difficulty = difficulty.parse(task[5]),
+ priority = priority.parse(task[6]),
description = task[7]
))
return res
-def insert(cursor: Cursor, form: ValidTaskForm):
+def insert(cursor: Cursor, s: Status, form: ValidTaskForm):
now = int(time.time())
cursor.execute(
" INSERT INTO tasks("
@@ -43,9 +49,10 @@ def insert(cursor: Cursor, form: ValidTaskForm):
" duration,"
" difficulty,"
" priority,"
- " description"
- " ) VALUES (?, ?, ?, ?, ?, ?, ?)",
- (now, now, form.name, form.duration, int(form.difficulty), int(form.priority), form.description))
+ " description,"
+ " status"
+ " ) VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
+ (now, now, form.name, form.duration, difficulty.format(form.difficulty), priority.format(form.priority), form.description, status.format(s)))
return Task(
id = cursor.lastrowid,
@@ -70,7 +77,7 @@ def update(cursor: Cursor, task: Task, form: ValidTaskForm):
" priority = ?,"
" description = ?"
" WHERE id = ?",
- (now, form.name, form.duration, int(form.difficulty), int(form.priority), form.description, task.id))
+ (now, form.name, form.duration, difficulty.format(form.difficulty), priority.format(form.priority), form.description, task.id))
return Task(
id = task.id,