Skip to content

Commit a623074

Browse files
committed
Fix tasks_ready SQL view
1 parent 66d175d commit a623074

2 files changed

Lines changed: 43 additions & 28 deletions

File tree

docs-source/concepts/states.md

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,27 @@ There are primary, secondary, and tertiary states.
1010
- `Open` - Waits to be done
1111
- `Closed` - Nothing left to be done
1212

13-
**9 exclusive secondary states:**
14-
15-
- `Asleep` - Is hidden because it's not relevant yet
16-
- `Awake` - Has become relevant or will become soon
17-
- `Ready` - Is ready to be done (similar to Open)
18-
- `Waiting` - It's still unclear if the task needs to be done or really has been
19-
done. Regular checks are necessary until situation clears up.
13+
**8 secondary states:**
14+
15+
They are not fully exclusive, as a task that should be reviewed is also ready.
16+
The info command, however, only shows the most relevant one.
17+
18+
- `Asleep` - Is hidden because it's not relevant yet. \
19+
E.g. the parcel can only be sent after `awake_utc`.
20+
- `Awake` - Has become relevant or will become soon. \
21+
E.g. the parcel could be sent now.
22+
- `Ready` - Is now ready to be done and should be started as soon as possible. \
23+
E.g. the parcel should be sent now.
24+
- `Waiting` -
25+
It is unclear if the task really has been done.
26+
Regular checks are necessary until situation clears up. \
27+
E.g. the parcel was sent and waiting for confirmation of receipt.
2028
- `Review` - It's necessary to check if the task can finally be started or
21-
if it has finally been completed.
22-
- `Done` - Has been done
23-
- `Obsolete` - Has become obsolete or impossible to finish
24-
- `Deletable` - Not needed anymore and can be deleted (item in the trash)
29+
if it has finally been completed. \
30+
E.g. investigate if the parcel has been sent or received.
31+
- `Done` - Has been done.
32+
- `Obsolete` - Has become obsolete or impossible to finish.
33+
- `Deletable` - Not needed anymore and can be deleted (item in the trash).
2534

2635
<!--
2736
TODO: Add Blocked
@@ -37,16 +46,16 @@ Table row:
3746

3847
State\Field|`awake_utc`|`ready_utc`|`waiting_utc`|`review_utc`|`closed_utc`|`state`
3948
-----------|:---------:|:---------:|:----------:|:---------:|:--------:|:------:
40-
**`Open`** | ❔ | ❔ | ❔ | ❔ | ❌ | ❌
41-
`└─Asleep` | > now |> now or ❌| ❌ | ❌ | ❌ | ❌
42-
`└─Awake` | < now |> now or ❌| ❌ | ❌ | ❌ | ❌
43-
`└─Ready` |< now or ❌| < now | ❌ | | ❌ | ❌
44-
`└─Waiting` | ❔ | ❔ | < now |> now or ❌| ❌ | ❌
45-
`└─Review` | ❔ | ❔ | ❔ | < now | ❌ | ❌
46-
**`Closed`** | ❔ | ❔ | ❔ | ❔ | ✅ | ❔
47-
`└─Done` | ❔ | ❔ | ❔ | ❔ | ✅ |`Done`
48-
`└─Obsolete` | ❔ | ❔ | ❔ | ❔ | ✅ |`Obsolete`
49-
`└─Deletable`| ❔ | ❔ | ❔ | ❔ | ✅ |`Deletable`
49+
**`Open`** | ❔ | ❔ | ❔ | ❔ | ❌ | ❌
50+
`└─Asleep` | > now | > now or ❌| ❌ | ❌ | ❌ | ❌
51+
`└─Awake` | < now | > now or ❌| ❌ | ❌ | ❌ | ❌
52+
`└─Ready` | < now or ❌| < now | ❌ | < now or ❌| ❌ | ❌
53+
`└─Waiting` | ❔ | ❔ | < now | > now or ❌| ❌ | ❌
54+
`└─Review` | ❔ | ❔ | ❔ | < now | ❌ | ❌
55+
**`Closed`** | ❔ | ❔ | ❔ | ❔ | ✅ | ❔
56+
`└─Done` | ❔ | ❔ | ❔ | ❔ | ✅ |`Done`
57+
`└─Obsolete` | ❔ | ❔ | ❔ | ❔ | ✅ |`Obsolete`
58+
`└─Deletable`| ❔ | ❔ | ❔ | ❔ | ✅ |`Deletable`
5059

5160
</small>
5261

@@ -58,7 +67,7 @@ Legend:
5867

5968
**3 exclusive tertiary states:**
6069

61-
- `Repeating` - If this task get completed, a duplicate will be created
70+
- `Repeating` - If this task gets completed, a duplicate will be created
6271
with the specified time offset.
6372
I.e. subsequent tasks get delayed
6473
(e.g. mowing the lawn)

tasklite-core/source/Migrations.hs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import Database.SQLite.Simple (
4545
)
4646
import Database.SQLite.Simple.QQ (sql)
4747
import Prettyprinter (Doc, Pretty (pretty), hardline)
48+
import FullTask (FullTask(awake_utc, review_utc))
4849

4950

5051
newtype UserVersion = UserVersion Int
@@ -743,18 +744,23 @@ _6_ =
743744
AND (review_utc > datetime('now') OR review_utc IS NULL)
744745
ORDER BY waiting_utc DESC
745746
|]
746-
, -- tasks_ready: Tasks ready to be worked on (not waiting, not scheduled)
747+
, -- tasks_ready: Tasks ready to be worked on
747748
[sql|
748749
CREATE VIEW tasks_ready AS
749750
SELECT *
750751
FROM tasks_view
751752
WHERE
752-
(ready_utc IS NULL
753-
OR (ready_utc IS NOT NULL AND ready_utc < datetime('now'))
753+
closed_utc IS NULL
754+
AND (
755+
review_utc <= datetime('now')
756+
OR ready_utc <= datetime('now')
757+
OR (
758+
ready_utc IS NULL
759+
AND (awake_utc IS NULL OR awake_utc <= datetime('now'))
760+
AND (waiting_utc IS NULL OR waiting_utc > datetime('now'))
761+
AND (review_utc IS NULL OR review_utc > datetime('now'))
762+
)
754763
)
755-
AND waiting_utc IS NULL
756-
AND ready_utc IS NULL
757-
AND closed_utc IS NULL
758764
ORDER BY
759765
priority DESC,
760766
due_utc ASC,

0 commit comments

Comments
 (0)