Synopsis
Logseq Journal does not show unfinished past-due TODOs
Description
Logseq will show a list of TODO items marked with SCHEDULED or DEADLINE at the bottom of your daily log, but only on the day they are due.
If you don't finish the TODO, it just drops off the list and you never see it again.
TLDR
Use the solution from Overdue deadline / schedule tasks not carried forward #1854:
First, add this to
{:title "Due Today"
:query [
:find (pull ?h [*])
:in $ ?end
:where
(or
[?h :block/scheduled ?d]
[?h :block/deadline ?d])
[?h :block/marker ?marker]
[(< ?d ?end)]
[(contains? #{"LATER" "TODO"} ?marker)]]
:inputs [:1d-after]
:collapsed? false}
And find and uncomment this:
:feature/disable-scheduled-and-deadline-query? true
What it does
This query will
- print the title "Due Today"
- bind the query argument "?end" to the value of 1 day after the current day.
- given ?end is "tomorrow"
- find all blocks
- where
- the block is scheduled or deadline
- and the block has a TODO or LATER marker
- and scheduled/deadline date is before tomorrow (today or earlier)
- Show those blocks, un-collapsed in the journal.
disable-scheduled-and-deadline-query will remove the default version.
Advanced Query
This is a Logseq Advanced Query.
Datoms
Everything (blocks, pages, etc.) in Logseq is stored in and queried via Datomic as collection of datoms in the form:
[id attribute value transaction]
- id - the id of the thing we're describing (i.e. a page or block)
- attribute - an identifier of the form :<thing type>/<attribute>, like :block/scheduled
- value - the value of that attribute for that id
- transaction - irrelevant to this article.
Datalog
The query itself is defined in datalog.
{...
:query [
:find ...
:in $ ?end
:where ... ]
:inputs [:1d-after]
...}
- :find (pull ...) - pull expression
- For our purposes this is always (pull ?h [*]).
- It's effectively SELECT *
- :in - :in $ ?arg1 ?arg2 define inputs to the query.
- $ is ignored.
- :in $ ?end defines a single argument called ?end
- :inputs [:1d-after] defines the query argument value
- 1d-after resolves to tomorrow
- :where - define the constraints used to filter the diatoms.
The :where
...
:where
(or
[?h :block/scheduled ?d]
[?h :block/deadline ?d])
[?h :block/marker ?marker]
[(< ?d ?end)]
[(contains? #{"LATER" "TODO"} ?marker)]
...
- (operator target argument) executes operator on target with arguments...
- [id attribute value] defines a data pattern where each slot is either a value or variable
- if a value, matching datoms must have that value
- if a variable, it is populated by matching datoms
- valid Logseq attribute values are defined in schema.cljs
- [(...)] defines a predicate which constrains what values a particular variable can have.
- (or [...] [...]) defines an or clause
- a diatom must match at least one of the data patterns or predicates.
- Datomic is based on Clojure so
With all of that:
- (or [?h :block/scheduled ?d] [?h :block/deadline ?d])
- :block/scheduled or :block/deadline must be defined
- the value, the scheduled date, is bound to ?d
- the entity id, the block, is bound to ?h
- [?h :block/marker ?marker]
- :block/marker must be defined
- the attribute value is bound to ?marker
- [(< ?d ?end)]
- ?d must be < ?end
- [(contains? #{"LATER" "TODO"} ?marker)]
- the clojure set of "LATER" and "TODO" must contain ?marker
Useful References
- the logseq schema with all the attributes.
- a great datalog tutorial (not Logseq specific) with interactive examples.
- the datomic query reference which has details not covered in the tutorial above.
- the Clojure core docs which includes a lot of basic language stuff datomic assumes you already know.
See Also
Author
Written by Michael Smit
Copyright
©2024 Michael Smit