TODOs under specific link

Hello everybody,

I use journals to keep track of work-things like this:

- # Work [[Company]]
	- ## [[Meeting]] about
	  Attendees: 
		- my meeting-notes
	- ## Todo
		- TODO ask something

And struggle creating two queries:

  1. one that shows all the TODOs with the [[Company]] (which should be inherited from the headline, right?)
  2. same as above but only from the last 7 days

Thank you for reading and maybe helping getting this to work

1 Like
  1. To get all of them:
    #+BEGIN_QUERY
    {
     :query [:find (pull ?todo [*])
       :where
         [?todo :block/marker "TODO"]
         [?company :block/original-name "Company"]
         [?todo :block/path-refs ?company]
     ]
    }
    #+END_QUERY
    
    • To limit in Journal, add these two lines:
           [?todo :block/page ?page]
           [?page :block/journal-day]
      
  2. To limit to last 7 days:
    #+BEGIN_QUERY
    {
     :inputs [:-6d :today]
     :query [:find (pull ?todo [*])
       :in $ ?start ?end
       :where
         [?todo :block/marker "TODO"]
         [?company :block/original-name "Company"]
         [?todo :block/path-refs ?company]
         (between ?todo ?start ?end)
     ]
    }
    #+END_QUERY
    
1 Like

Oh, sorry, I forgot to thank you for your answer!
I remember that I was surprised by your fast answer and that I should answer and thank you!
Thank you for your answer, this has been very helpfull!