logseq_fix_scheduled_todos(1)
Make Logseq Show Unfinished TODOS
logseq_fix_scheduled_todos(1)
______ __ __ / ____/___ ____/ /__ _____/ /_ ___ ____________ __ / / / __ \/ __ / _ \/ ___/ __ \/ _ \/ ___/ ___/ / / / / /___/ /_/ / /_/ / __/ / / /_/ / __/ / / / / /_/ / \____/\____/\__,_/\___/_/ /_.___/\___/_/ /_/ \__, / /____/
______ __ __ / ____/___ ____/ /__ _____/ /_ _ _ / / / __ \/ __ / _ \/ ___/ __ \/ / / / / /___/ /_/ / /_/ / __/ / / /_/ / /_/ / \____/\ODER/\__,_/\___/_/ /_.___/\_, / ERRY/
______ __ / ____/___ / /_ _ _ / / / __ \/ __ \/ / / / / /___/ /_/ / /_/ / /_/ / \____/\ODER/\_.__/\_, / ERRY/

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 /logseq/config.edn under the :default_queries section:

{: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
    • Some operations are defined by Datomic
    • But other things are part of Clojure

With all of that:

  1. (or [?h :block/scheduled ?d] [?h :block/deadline ?d])
  2. [?h :block/marker ?marker]
    • :block/marker must be defined
    • the attribute value is bound to ?marker
  3. [(< ?d ?end)]
    • ?d must be < ?end
  4. [(contains? #{"LATER" "TODO"} ?marker)]

Useful References

See Also

Author

Written by Michael Smit

Copyright

©2024 Michael Smit