How to quickly open the parent page (e.g. the journal page) of a TODO block that is shown in a query?

I use queries to show ToDos on the journal page. Very often I find that I need to go to the parent page of the TODO-block that is shown in the query, but I lack a way of doing this… I only know that I can click on the bullet of the TODO block, but that will open only it in its own page, but NOT the parent-page.
In other words I would like some way to open e.g. the journal page, where the TODO item was created (ideally it should highlight that TODO item to quickly locate it).

What is the query you use? Because if you return full blocks their page should be included.

The query looks like this, which is an excerpt from my config.edn:

	    {:title [:h4 "⏰ Today"]
	      :query [:find (pull ?block [*])
		      :in $ ?start ?next
		        [?block :block/scheduled ?d]
		        [?block :block/deadline ?d])
		      [(> ?d ?start)]
		      [(< ?d ?next)]]
	      :result-transform (fn [result]
		        (sort-by (fn [h]
		                    (or (get h :block/scheduled) (get h :block/deadline))) result))
	      :inputs [:1d-before :1d-after]
	      :collapsed? false},
;; more queries here ...

I found this query on this thread: Why I no longer use LOGseq for taskmanagement (but somehow still do) - #4 by mlanza

Yes I see, the problem is with the :result-transform. This causes the normal block return to be overridden and so the page is no longer displayed.
There’s more people dealing with this issue.
See also here: Post processing queries to acheive better sorting - #3 by 4nthony

I am just returning to this…
I am still very new to Logseq and even more regarding queries. For the moment I would like to only use it to manage my ToDos as I am getting familiar with it…
From the thread that you linked, I fail to find a concrete solution to this problem.
Do you have a suggestion?
In addition, do you know a good introductory tutorial on how to write advanced queries?
For instance, at the moment, I do not even understand the meaning of fn [result] ... in:

	      :result-transform (fn [result]
		        (sort-by (fn [h]
		                    (or (get h :block/scheduled) (get h :block/deadline))) result))

So I am very far from coming up with a solution …
I would be very grateful for any input. Thanks for considering!

There is no real solution here.
Either don’t use result-transform. Or click on the bullet and go from there.
Neither are very helpful unfortunately.

Clojure functions: (i.e. that (fn [result] result) syntax)
This goes into learning closure as a whole: Clojure from the ground up: welcome
This is a reference to search up what you come across in queries so you can find what it does: clojure.core namespace | ClojureDocs - Community-Powered Clojure Documentation and Examples

1 Like

FWIW, I was having your same problem/question, and found that by setting the :group-by-page? true in the query, the found blocks are presented in a visual grouping titled like the parent journal page. So I can click in there directly.
It’s perfect for what I wanted, maybe it’d also be OK for you?

That doesn’t work in combination with :result-transform.

To illustrate, query result as is:

Query result with :group-by-page? true:

As you can see the sorting is gone now.