How to query all TODOs from a given page?

Hi all. I searched some of the other query topics but haven’t been able to figure this out. I have some generic TODOs that live in the daily pages, and some project specific TODOs that live on those pages. I’m trying to edit the :default-queries in config.edn to show both in separate queries. Below you can see my attempt—it properly shows the generic TODOs from daily pages, but does not show the project-specific TODOs on the “My Project TODO” pages.

You can see I tried a very simply query where I just list blocks on the page, but that also did not work. I’ve tried lowercasing the page name and tried other pages, so I feel like I must be missing something obvious or misunderstanding some syntax here. How do I get this working? Thanks!

:default-queries
 {:journals
  [
	{:title "Simple Test Query"
	 :query [:find (pull ?h [*])
         :where
         [?h :block/page "My Project TODO"]]}
   
   {:title "My Project TODO"
    :query [:find (pull ?h [*])
            :where
            [?h :block/marker ?marker]
            [(contains? #{"NOW" "DOING" "TODO" "LATER" "WAITING"} ?marker)]
            [?h :block/name "My Project TODO"]]
    :result-transform (fn [result]
                        (sort-by (fn [h]
                                   (get h :block/priority "Z")) result))
    :group-by-page? false
    :collapsed? false}

   {:title "🔨 TODO"
    :query [:find (pull ?h [*])
            :in $ ?start ?today
            :where
            [?h :block/marker ?marker]
            [(contains? #{"NOW" "DOING" "TODO" "LATER" "WAITING"} ?marker)]
            [?h :block/page ?p]
            [?p :block/journal? true]
            [?p :block/journal-day ?d]
            [(>= ?d ?start)]
            [(<= ?d ?today)]]
    :inputs [:365d :today]
    :result-transform (fn [result]
                        (sort-by (fn [h]
                                   (get h :block/priority "Z")) result))
    :group-by-page? false
    :collapsed? false}

   {:title "📅 NEXT"
    :query [:find (pull ?h [*])
            :in $ ?start ?next
            :where
            [?h :block/marker ?marker]
            [(contains? #{"NOW" "LATER" "TODO"} ?marker)]
            [?h :block/page ?p]
            [?p :block/journal? true]
            [?p :block/journal-day ?d]
            [(> ?d ?start)]
            [(< ?d ?next)]]
    :inputs [:today :7d-after]
    :group-by-page? false
    :collapsed? false}]}

Welcome.

  • :block/page gives an id
  • :block/name gives the name of the page in lower-case
  • :block/original-name gives the name of the page in its original case

Your task is on the page with :block/name “my project todo”. The task itself is not that page.

Thus follows,

{:title "My Project TODO"
 :query [:find (pull ?h [*])
  :where
   [?h :block/marker ?marker]
   [(contains? #{"NOW" "DOING" "TODO" "LATER" "WAITING"} ?marker)]
   [?h :block/page ?p]
   [?p :block/name "my project todo"] ;name is always lower-case
 ]
 :result-transform (fn [result]
  (sort-by (fn [h]
    (get h :block/priority "Z")) result))
 :group-by-page? false
 :collapsed? false}
1 Like

Ahh I see. This is perfect, thanks so much @Siferiax!

1 Like