So two things.
- 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]) - 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
?dwithin our or statement. We don’t want to bind it with the rest of our query.
Otherwise you basically had it
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: