aboutsummaryrefslogtreecommitdiff
path: root/src/db
diff options
context:
space:
mode:
authorJoris2020-05-10 12:50:46 +0200
committerJoris2020-05-10 12:50:46 +0200
commit7372ab407535ade48ce0b642ae051990e3bef7ed (patch)
tree65ae22d72cf10e40e777c4fa1919539d8e065e46 /src/db
parenta134f20eb62e6d174e7da81fd4adb7ff9e8b3b71 (diff)
Add task difficulty and priority fields
Diffstat (limited to 'src/db')
-rw-r--r--src/db/init.py6
-rw-r--r--src/db/tasks.py44
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):