aboutsummaryrefslogtreecommitdiff
path: root/src/db
diff options
context:
space:
mode:
authorJoris2020-06-01 09:11:02 +0200
committerJoris2020-06-01 09:11:02 +0200
commit3844f76d18e376777ca4d7c124df6d6b4896a361 (patch)
tree425a2380f960f81f929b1b1b6e860bd42626127d /src/db
parentadfab777568215d3c72facf07b734c1ff6046d78 (diff)
Separate tasks panel on status
Diffstat (limited to 'src/db')
-rw-r--r--src/db/init.py3
-rw-r--r--src/db/tasks.py25
2 files changed, 18 insertions, 10 deletions
diff --git a/src/db/init.py b/src/db/init.py
index 77920cf..5d847a3 100644
--- a/src/db/init.py
+++ b/src/db/init.py
@@ -21,7 +21,8 @@ def init(path):
" duration INTEGER,"
" difficulty INT,"
" priority INT,"
- " description TEXT"
+ " description TEXT,"
+ " status TEXT"
" )")
cursor.execute(
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,