Help with tasks query

Hi everyone,

I struggle with a query that finds TODOs in my current page and blocks linked to it. Results are ordered by priority. For the moment that is almost everything I need. But one thing would be nice: I am looking for a way to group the query results by priorities and make the groups visually more clear. Ideal would be styled grey boxes per priotity, as there are in default queries for pages.

Here is my query so far:

#+BEGIN_QUERY
{:title [:b "TODO List current page, sorted by priority"]
 :query [:find (pull ?b [*])
   :in $ ?current
   :where
     [?b :block/marker "TODO"]
     [?p :block/name ?current]
     [?b :block/path-refs ?p]]
   :result-transform (fn [result]
                      (sort-by (fn [h]
                                 (get h :block/priority "Z")) result))
:inputs [:current-page]}
#+END_QUERY

Any help is appreciated!
Cheers Falko

Hello there! Just discard my suggestion if you find it too simple, innocent or inadequate - I just found logseq one month ago!
I use a simple live query for TODOs,

{{query (task TODO)}}

In my use case, this simple approach works really well - I believe I’ve seen it on a tutorial. I also combine it with a DONE live query on the same page

{{query (task DONE)}}

This way I’ve everything (task-related) on a page - I did not have messed with priorities yet.

Hope it helps somehow!