diff options
Diffstat (limited to 'src/db')
-rw-r--r-- | src/db/init.py | 6 | ||||
-rw-r--r-- | src/db/tasks.py | 44 |
2 files changed, 32 insertions, 18 deletions
diff --git a/src/db/init.py b/src/db/init.py index cb8a4a8..83e73f2 100644 --- a/src/db/init.py +++ b/src/db/init.py @@ -12,9 +12,11 @@ def init(path): " created_at INTEGER NOT NULL," " modified_at INTEGER NOT NULL," " name TEXT NOT NULL," - " description TEXT," " duration INTEGER," - " tag TEXT" + " tag TEXT," + " difficulty INT," + " priority INT," + " description TEXT" " )") database.commit() return database diff --git a/src/db/tasks.py b/src/db/tasks.py index e22a315..5fdd25e 100644 --- a/src/db/tasks.py +++ b/src/db/tasks.py @@ -10,9 +10,11 @@ def get(cursor: Cursor) -> Task: " created_at," " modified_at," " name," - " description," " duration," - " tag" + " tag," + " difficulty," + " priority," + " description" " FROM tasks") res = [] @@ -23,9 +25,11 @@ def get(cursor: Cursor) -> Task: created_at = task[1], modified_at = task[2], name = task[3], - description = task[4], - duration = task[5], - tag = task[6] + duration = task[4], + tag = task[5], + difficulty = task[6], + priority = task[7], + description = task[8] )) return res @@ -37,20 +41,24 @@ def insert(cursor: Cursor, form: ValidTaskForm): " created_at," " modified_at," " name," - " description," " duration," - " tag" - " ) VALUES (?, ?, ?, ?, ?, ?)", - (now, now, form.name, form.description, form.duration, form.tag)) + " tag," + " difficulty," + " priority," + " description" + " ) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", + (now, now, form.name, form.duration, form.tag, int(form.difficulty), int(form.priority), form.description)) return Task( id = cursor.lastrowid, created_at = now, modified_at = now, name = form.name, - description = form.description, duration = form.duration, - tag = form.tag + tag = form.tag, + difficulty = form.difficulty, + priority = form.priority, + description = form.description ) def update(cursor: Cursor, task: Task, form: ValidTaskForm): @@ -61,20 +69,24 @@ def update(cursor: Cursor, task: Task, form: ValidTaskForm): " SET" " modified_at = ?," " name = ?," - " description = ?," " duration = ?," - " tag = ?" + " tag = ?," + " difficulty = ?," + " priority = ?," + " description = ?" " WHERE id = ?", - (now, form.name, form.description, form.duration, form.tag, task.id)) + (now, form.name, form.duration, form.tag, int(form.difficulty), int(form.priority), form.description, task.id)) return Task( id = task.id, created_at = task.created_at, modified_at = now, name = form.name, - description = form.description, duration = form.duration, - tag = form.tag + tag = form.tag, + difficulty = form.difficulty, + priority = form.priority, + description = form.description ) def delete(cursor: Cursor, ids): |