How to filter out blocks with page refs that have specific page property values?

Hello,

I want to rewrite the query below to do what it does now but filter OUT those TODO blocks that meet two criteria at the same time:

  1. Contain/inherit one or more page refs with the page property “status::”
  2. But none of them have a page property status = NOT {canceled, done, waiting, blank}.

So, for example, if one of the page refs contained/inherited has a property status = DOING, then the block is included regardless of the property status of the other page refs.

Thanks!

#+BEGIN_QUERY
{:title [:h4 "Current page relevant TODOs"]
:query 
(and 
[[important]]
(not [[postponed]])
(not [[later]] )
(task NOW LATER DOING IN-PROGRESS TODO WAIT WAITING) 
<%current page%>
)
:result-transform (fn [result]
                   (sort-by (fn [b]
                              (get b :block/priority "Z")) result))
:breadcrumb-show? true
:collapsed? false
}
#+END_QUERY
  • Your description is quite difficult to follow.
  • Here is a query based on my understanding of your description:
#+BEGIN_QUERY
{:title [:h4 "Current page relevant TODOs"]
 :query [:find (pull ?b [*])
   :where
     [?b :block/marker ?marker]
     [(contains? #{"NOW" "LATER" "DOING" "IN-PROGRESS" "TODO" "WAIT" "WAITING"} ?marker)]
     [?b :block/refs ?ref1]
     [?ref1 :block/name "important"]
     (not
       [?b :block/refs ?ref2]
       [?ref2 :block/name "postponed"]
     )
     (not
       [?b :block/refs ?ref3]
       [?ref3 :block/name "later"]
     )
     (not
       [?b :block/refs ?status-ref1]
       [?status-ref1 :block/properties ?props1]
       [(get ?props1 :status) ?status1]
       (not
         [?b :block/refs ?status-ref2]
         [?status-ref2 :block/properties ?props2]
         [(get ?props2 :status) ?status2]
         [(contains? #{"canceled" "done" "waiting" ""} ?status2)]
       )
     )
 ]
 :result-transform (fn [result]
                     (sort-by (fn [b]
                       (get b :block/priority "Z")) result))
 :breadcrumb-show? true
 :collapsed? false
}
#+END_QUERY