I asked chatgpt to create an advanced Logseq query that basically grabs all the blocks in the journal page with some stated conditions, but the code it gives always fail at some point or doesn’t show what I want. Here are the conditions (note: they are OR conditions):
- Condition 1: Captures tasks with the marker
DOING
in journal pages. - Condition 2: Captures tasks with
TODO
that have aSCHEDULED
property where the scheduled date is earlier/less than today. - Condition 3: Captures tasks with
DOING
that also have aSCHEDULED
property where the scheduled date is earlier/less than today
And here is the code it created:
#+BEGIN_QUERY
{:title "📝 Filtered Tasks"
:query [:find (pull ?b [*])
:in $ ?today
:where
(or
;; Condition 1: Tasks with DOING marker
(and
[?b :block/marker "DOING"]
[?b :block/page ?page]
[?page :block/journal? true])
;; Condition 2: Tasks with TODO and SCHEDULED dates less than today
(and
[?b :block/marker "TODO"]
[?b :block/scheduled ?scheduled]
[(< ?scheduled ?today)]
[?b :block/page ?page]
[?page :block/journal? true])
;; Condition 3: Tasks with DOING and SCHEDULED dates less than today
(and
[?b :block/marker "DOING"]
[?b :block/scheduled ?scheduled]
[(< ?scheduled ?today)]
[?b :block/page ?page]
[?page :block/journal? true]))]
:inputs [:today]
:result-transform (fn [results]
(sort-by (fn [h]
(get h :block/priority "Z")) results))
:collapsed? false
:breadcrumb-show? false}
#+END_QUERY
And here is the error the code gave on Logseq:
I tried troubleshooting it with chatgpt but I don’t know much about Datalog. Can someone help me? Thanks.