This one was really fun to build. As mentioned in my previously shared query (Advanced Query that pulls all reference AND recursive name spaces - #5 by CappieXL ), the way queries, namespaces, and aliases work together makes it hard for me to get it working to my liking. Therefore, I tried to go another route and instead of name spaces aggregate tasks based on page-tags.
I call this the “tag-based task aggregator”. Basically what it does, is that it collects all the tasks that are:
- on the current-page; or
- path-reference the current-page; or
- are on a page that has the current page as a tag; or
- path-reference a page that has the current page as a tag.
So imagine you’re working at “Bedrijf A”, which does a project “Project A.X” together with a client “Klant X”. If you’re like me, you jot everything down in the daily journal. So if my client calls me, I quickly make a task and I tag the project. Because the project has a page tag to both Bedrijf A and Klant X, the task will land on their task lists too.
Here are some screenshots:
To me this has two major advantages:
- I do not need to clutter my workflow with very long nested namespaces
- It becomes really intuitive. I can create project pages and just tag all the task lists i would like those tasks to show up.
Here’s the query:
#+BEGIN_QUERY
{:title "?currentpage taken"
:query [:find (pull ?b [*])
:in $ ?current-page
:where
(task ?b #{"NOW" "LATER" "DOING" "TODO"})
(?p :block/name ?current-page)
(or
(and [?page :block/name ?page] [?b :block/path-refs ?p] )
(and (?page :block/tags ?p) [?b :block/path-refs ?page])
)
]
:result-transform (fn [result] (sort-by (fn [r] (get r :block/content)) result))
:group-by-page? false
:breadcrumb-show? false
:inputs [:current-page]
}
#+END_QUERY