Znyzer
1
I have this query with the following conditions:
- Show blocks with DOING marker OR;
- Show blocks with TODO, DOING and is SCHEDULEd today OR;
- Show blocks with TODO, DOING and whose DEADLINE is today
#+BEGIN_QUERY
{:title "π
**TODAY**"
:query [:find (pull ?b [*])
:in $ ?today
:where
[?b :block/marker ?marker]
[?b :block/page ?page]
[?page :block/journal? true]
(or
[(= ?marker "DOING")]
[?b :block/scheduled ?date]
[?b :block/deadline ?date]
) ;; OR condition for "DOING" marker
[(= ?date ?today)]
[(contains? #{"NOW" "TODO" "LATER" "WAITING" "DOING"} ?marker)]]
:inputs [:today]
:result-transform (fn [results]
(sort-by (fn [h]
(get h :block/priority "Z")) results))
:collapsed? false
:breadcrumb-show? false}
#+END_QUERY
However, the query shows nothing (see block highlighted in blue below):
Whatβs wrong with the query?
Znyzer
2
I rewrote the code. However, I still get no results
#+BEGIN_QUERY
{:title "π
**TODAY**"
:query [:find (pull ?b [*])
:in $ ?today
:where
[?b :block/marker ?marker]
[?b :block/page ?page]
[?page :block/journal? true]
(or
(and [?b :block/scheduled ?date]
[(= ?date ?today)])
(and [?b :block/deadline ?date]
[(= ?date ?today)])
[?b :block/marker "DOING"]) ;; Show "DOING" blocks regardless of date
[(contains? #{"NOW" "TODO" "LATER" "WAITING" "DOING"} ?marker)]]
:inputs [:today]
:result-transform (fn [results]
(sort-by (fn [h]
(get h :block/priority "Z")) results))
:collapsed? false
:breadcrumb-show? false}
#+END_QUERY
Znyzer
4
Thanks.
For posterity, here is the query that satisfies these conditions:
#+BEGIN_QUERY
{:title "π
**TODAY & DOING**"
:query [:find (pull ?b [*])
:in $ ?today
:where
;; Match blocks with a valid marker
[?b :block/marker ?marker]
;; Match blocks in journal pages
[?b :block/page ?page]
[?page :block/journal? true]
;; Match blocks based on scheduled, deadline, or "DOING" marker
(or-join [?b ?today]
;; Match blocks scheduled for today
(and [?b :block/scheduled ?date]
[(= ?date ?today)])
;; Match blocks with a deadline for today
(and [?b :block/deadline ?date]
[(= ?date ?today)])
;; Match blocks marked as "DOING"
[?b :block/marker "DOING"])
;; Filter blocks with specific markers
[(contains? #{"NOW" "TODO" "LATER" "WAITING" "DOING"} ?marker)]]
:inputs [:today]
:result-transform (fn [results]
;; Sort by priority, defaulting to "Z" for missing priority
(sort-by (fn [h]
(get h :block/priority "Z"))
results))
:collapsed? false
:breadcrumb-show? false}
#+END_QUERY
Happy Christmas everyone!





1 Like