I have a query for all tasks that are now, and I use the table view for the query. The problem is that many of these tasks are sub-blocks of other tasks and often only make sense in context. So I would like to have one of the fields in the query table show the uppermost block that the task belongs to.
Something like this:
#+BEGIN_QUERY
{:query [:find ?context (pull ?b [*])
:keys context b
:in $ %
:where
[?b :block/marker ?marker]
[(contains? #{"NOW"} ?marker)]
(context ?b ?context-b)
[?context-b :block/content ?context]
]
:rules [
[(context ?b ?context)
[?b :block/parent ?context]
[?context :block/parent ?p]
[?p :block/name]
]
[(context ?b ?context)
[?b :block/parent ?parent]
(context ?parent ?context)
]
]
:result-transform (fn [result]
(map (fn [r]
(update (:b r) :block/properties (fn [p]
(assoc p "context" (:context r))
) )
) result)
)
}
#+END_QUERY
Thanks! It’s close, but a few things I would like to change:
-
The context displays the “logbook” which adds a lot of clutter.
-
The context displays the properties on separate lines, which takes up a lot of vertical space. Is it possible to put this all on one line? Or just hide the properties.
-
For the block column, can I give it a maximum width, and longer entries would be either forced onto multiple lines or just abbreviated with
…?
- Your requirements go beyond queries and into coding.
- For a non-coding alternative, consider changing your blocks like this:
- To remove the clutter from the context column:
- Nest context blocks under new blocks that contain only the text that you want to be displayed.
- Just a title should be enough.
- Nest context blocks under new blocks that contain only the text that you want to be displayed.
- To remove the need of abbreviating long block columns:
- Move excessive content of such blocks inside sub-blocks.
- This is a good thing to do anyway.
- Move excessive content of such blocks inside sub-blocks.
- To remove the clutter from the context column: