Forgot this existed

This commit is contained in:
Tristan Ancelet
2023-08-29 12:01:57 -05:00
parent a27e7f561e
commit f254b397a4
6 changed files with 41 additions and 3 deletions

20
scripts/utils/get-task.sh Normal file
View 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
View 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;