Tasks linked to the current page, scheduled for today or earlier, or not scheduled at all

So two things.

  1. we don’t want to check whether it has scheduled ?d, we want to check that it doesn’t have a value at all. So (not [?b :block/scheduled])
  2. we need an or-join here instead of an or. We are looking for a logical or as it’s called. We only need the variable ?d within our or statement. We don’t want to bind it with the rest of our query.
    Otherwise you basically had it :slight_smile: here’s the complete query.
#+BEGIN_QUERY
{:title "Tasks"
:query [:find (pull ?b [*])
    :in $ ?current-page ?today
    :where
    [?p :block/name ?current-page]
    [?b :block/refs ?p]
     (or-join [?b ?today] ; so or-join and bind both ?b and ?today
       (and 
         [?b :block/scheduled ?d]
         [(<= ?d ?today)]
       )
       (not [?b :block/scheduled])
     )
    (task ?b #{"TODO", "DOING"})
]
:inputs [:current-page :today]
}
#+END_QUERY

In my on-going effort to compile task management queries, I’ll link this topic:

2 Likes