I have projects, and I want to list all available works. There are two kinds of works, one is #order_list and another is #work_list. The works in #order_list should be done according to the order, and works of #work_list can be done regardless of the order.
So, I need to filter the first available work of #order_list and all works of #work_list. However, when I want to load the first work of #order_list, my query doesn’t work well and return no result.
Here is my query code
;; #+BEGIN_QUERY
{:title [:b "Next Task"]
:query [:find (pull ?b [*])
:in $ %
:where
[?b :block/marker "TODO"]
[?b :block/parent ?t]
[?b :block/refs ?refs]
[?refs :block/name "order_list"]
(not ; ?b doesn't have an open child.
[?c :block/parent ?b]
[?c :block/marker "TODO"]
)
(not (findleft ?b) ) ; ?b doesn't have an earlier task in the list
]
:rules [
[(findleft ?b)
[?b :block/parent ?m]
(not [?m :block/name])
[?b :block/left ?l]
[(!= ?l ?m)]
[?l :block/marker "TODO"]
]
[(findleft ?b)
[?b :block/parent ?m]
(findleft ?m)
]
]
}
;; #+END_QUERY
Is there any wrong of my query code?
Thanks for help!