Forgot this existed
This commit is contained in:
20
scripts/utils/get-task.sh
Normal file
20
scripts/utils/get-task.sh
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/bash
|
||||
: "
|
||||
get_task_number
|
||||
This function will query sqlite db to either get the number of a task OR create the task and return the number
|
||||
|
||||
returns:
|
||||
-1 - Experienced error
|
||||
0 - Task was found
|
||||
1 - Task was created
|
||||
"
|
||||
function get_task_number() {
|
||||
local DB_PATH="${FILES_DIR:?"FILES_DIR was not set"}/task.db"
|
||||
local TASK_TITLE="${1:?"Task title was not provided"}"
|
||||
|
||||
local TASK_NUMBER="$(
|
||||
sqlite3 $DB_PATH <<< "
|
||||
SELECT
|
||||
"
|
||||
)"
|
||||
}
|
14
scripts/utils/task-db.sql
Normal file
14
scripts/utils/task-db.sql
Normal file
@@ -0,0 +1,14 @@
|
||||
CREATE TABLE IF NOT EXISTS tasks (
|
||||
TASK_ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
TASK_TITLE TEXT NOT NULL,
|
||||
TASK_CREATION_DATE DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
TASK_DUE_DATE DATETIME DEFAULT DATETIME(CURRENT_TIMESTAMP, '+7 day')
|
||||
);
|
||||
|
||||
CREATE VIEW tasks_by_creation AS
|
||||
SELECT TASK_ID task_number, TASK_TITLE task_title, DATE(TASK_CREATION_DATE) creation_date FROM tasks
|
||||
ORDER BY TASK_CREATION_DATE ASC;
|
||||
|
||||
CREATE VIEW tasks_by_duedate AS
|
||||
SELECT TASK_ID task_number, TASK_TITLE task_title FROM tasks
|
||||
ORDER BY TASK_DUE_DATE ASC;
|
Reference in New Issue
Block a user