-
-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathheadings.sh
More file actions
34 lines (30 loc) · 954 Bytes
/
headings.sh
File metadata and controls
34 lines (30 loc) · 954 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
myPluginID="$(getNextPluginID)"
myPlugin="plugin$myPluginID"
myPluginCommand="headings"
myPluginDescription="Shows $LIMIT_BY headings ordered by '$ORDER_BY'"
myPluginMethod="queryHeadings"
eval "$myPlugin=('$myPluginCommand' '$myPluginDescription' '$myPluginMethod')"
queryHeadings() {
sqlite3 "$THINGSDB" "$(getHeadingsQuery)"
}
getHeadingsQuery() {
read -rd '' query <<-SQL || true
SELECT
CASE
WHEN AREA.title IS NOT NULL THEN AREA.title
WHEN PROJECT.title IS NOT NULL THEN PROJECT.title
WHEN HEADING.title IS NOT NULL THEN HEADING.title
ELSE "(No Context)"
END,
TASK.title
FROM $TASKTABLE TASK
LEFT OUTER JOIN $TASKTABLE PROJECT ON TASK.project = PROJECT.uuid
LEFT OUTER JOIN $AREATABLE AREA ON TASK.area = AREA.uuid
LEFT OUTER JOIN $TASKTABLE HEADING ON TASK.heading = HEADING.uuid
WHERE TASK.$ISNOTTRASHED AND TASK.$ISOPEN AND TASK.$ISHEADING
ORDER BY TASK.$ORDER_BY
LIMIT $LIMIT_BY
SQL
echo "$query"
}