Query scheduled/deadline blocks but remove finished tasks

Hey,

i have query question which i’m not able to solve.
As result I want to have a list of blocks, which have the /scheduled and/or /deadline property set to today.
With a much simpler query it works for blocks/tasks and everything, but now I want to additionally filter out tasks which are already done (task DONE, CANCELLED, …)

My provided query is currently invalid, i’m not sure if I use the “or-join” correctly, with “or” i only get a empty list.

maybe someone of you can help me
thank you very much in advance.

#+BEGIN_QUERY
{:title [:h4 "⏰ Today"]
      :query [:find (pull ?block [*])
              :in $ ?day
              :where
(or
  [?block :block/scheduled ?d]
  [?block :block/deadline ?d]
 )
[(= ?d ?day)]]
(or-join [?block _] 
  (and
    [?block :block/marker ?marker]
    [(not= ?marker "DONE")]
  )
  (not [?block :block/marker])
)
      		  :inputs [:today]
              :breadcrumb-show? false
      		  }
#+END_QUERY

Your query has some syntax issues mainly.
I corrected the syntax. Also the marker check syntax was incorrect. not= should be !=, but I rewrote that so you can exclude multiple states.

#+BEGIN_QUERY
{:title [:h4 "⏰ Today"]
 :query [:find (pull ?block [*])
   :in $ ?day
   :where
     (or
       [?block :block/scheduled ?d]
       [?block :block/deadline ?d]
     )
     [(= ?d ?day)]
     (or-join [?block] 
       (and
         [?block :block/marker ?marker]
         (not [(contains? #{"DONE" "CANCELED"} ?marker)])
       )
       (not [?block :block/marker])
     )
 ]
 :inputs [:today]
 :breadcrumb-show? false
}
#+END_QUERY

Thank you very much for your solution. Works very good :wink:

1 Like