Query all TODOs under journal pages

Hi,

I’m trying to fetch all the past TODOs under my journal pages. But I’m having a problem getting tags that are nested like this

[2022/03/28]
     TODO Something 1
     TODO Something 2

Using this query I’m able to find all TODOs on all my pages, included the ones nestes as above

#+BEGIN_QUERY
{:title "Find: tagged tasks"
:query [:find (pull ?b [* {:block/_parent ...}])
:where
	[?b :block/marker ?marker]
	[(contains? #{"TODO" "LATER" "NOW"} ?marker)]
	
	[?b :block/ref-pages ?p]
	[?p :block/name ?tag]
	]
}
#+END_QUERY

And by using this Query I am able to get all todos under my journal page. However, not the once that are nested as above.

#+BEGIN_QUERY
{:title "🗄️ Forgotten"
    :query [:find (pull ?h [*])
            :in $ ?start ?next
            :where
            [?h :block/marker ?marker]
            [?h :block/page ?p]
            [?p :page/journal? true]
            [?p :page/journal-day ?d]
            [(> ?d ?start)]
            [(< ?d ?next)]
            [(contains? #{"NOW" "DOING" "LATER" "TODO"} ?marker)]]
    :inputs [:365d :14d]
    :result-transform (fn [result]
                        (sort-by (fn [h]
                                   (get h :block/priority "Z")) result))
    :collapsed? true}
#+END_QUERY

Is there anyway I can modify either of these to find all my todos on the journal pages?

Thanks in advance!

Your query finds all tasks on journal pages, which ones are you missing? Tasks on non-journal pages, but tagged with a journal?

Hi thanks for you response.

The query that finds all the journal todos, don’t seem to find nested todos as the example you quoted above.

What is [2022/03/28]? It is not a (legitimate) tag. How many blocks are there? It is not clear from the screenshot. Maybe you could show the markdown source?

Hi so my workflow has been that I add things to do tomorrow (or someday in the future) by creating a date and then nest my todos under it. For example, I do a tag for tomorrow and then add my todos as below:

[2022/03/31]
    TODO 1
    TODO 2

Hence, my tags are 1) the date tag and 2) the TODO tag.
Now, I want to query all the todos that are on my journal page included the once that are nested as above. However, I’ve only been able to figure out a query that finds non-nested todos for the journal page.

In my workflow, it is more important for me to know if I have high priority Tasks, Overdue Tasks and what is due that day and tomorrow. I put this code in my Config file:

{:journals
[{:title “:izakaya_lantern: OVERDUE”
:query [:find (pull ?block [])
:in $ ?today
:where
[?block :block/marker ?marker]
[(contains? #{“DOING” “TODO” “LATER” “WAITING”} ?marker)]
(or
[?block :block/scheduled ?d]
[?block :block/deadline ?d])
[(< ?d ?today)]]
:inputs [:today]
:collapsed? false}
{:title “:green_circle: High Priority”
:query (and [[A]] (not [[DONE]]))
:collapsed? false}
{:title “:hammer: NOW”
:query [:find (pull ?h [
])
:in $ ?start ?today
:where
[?h :block/marker ?marker]
[(contains? #{“NOW” “DOING”} ?marker)]
[?h :block/page ?p]
[?p :block/journal? true]
[?p :block/journal-day ?d]
[(>= ?d ?start)]
[(<= ?d ?today)]]
:inputs [:14d :today]
:result-transform (fn [result]
(sort-by (fn [h]
(get h :block/priority “Z”)) result))
:collapsed? false}
{:title “:date: NEXT”
:query [:find (pull ?h [*])
:in $ ?start ?next
:where
[?h :block/marker ?marker]
[(contains? #{“NOW” “LATER” “TODO”} ?marker)]
[?h :block/ref-pages ?p]
[?p :block/journal? true]
[?p :block/journal-day ?d]
[(> ?d ?start)]
[(< ?d ?next)]]
:inputs [:today :7d-after]
:collapsed? false}]}

1 Like