Is it possible to change query output form and what are the syntaxes?

I have made a default query to show all doing jobs that works fine. However, is it possible to show page name instead of the TODO block. So that I can directly link to the page while clicking on it. (i.e. the following image Mid-term Report is quite vague since I don’t know the project it belongs too, and I have no direct link to it.)

This is the query I used and the result:

 :default-queries
 {:journals
  [
	{
    	:title [:b "Current Tasks"]
    	:query [:find (pull ?b [*])
                :where
                	[?b :block/marker ?marker]
                	[(contains? #{"DOING"} ?marker)]  ; TODO put in a value list with LATER.
					[?h :block/page ?p]
                ]
		:result-transform (fn [result] (sort-by (fn [h] (get h :block/priority "Z")) result)); sort the result by the priority
    	:table-view? false
		:breadcrumb-show? false  ; don't show the parent blocks in the result !important, due to result-transform the grouping is lost, and so you will be left with a simple list of TODO items. having those parents blocks mixed in may make the list more confusing. (setting this to true won't show the page btw!)
    	:collapsed? false
	}
 ]
}

And this is what I would like to achieve (table view is fine too), and the ability to link to the page by pressing Project A block.

  1. Table view isn’t possible in default queries
  2. Result-transform is not compatible with group-by-page.

If you remove the result-transform you get that grouping back, and therefore the page names, but you lose your sort.

A possible solution is a custom view, but then you loose the way the tasks show now as that is a specific logseq view you would override.

It’s not a helpful response, I’m aware.
The result-transform sorting should be compatible with group-by-page, but this is not how the devs have implemented it. Probably due to the enormous amount of things you can do with result-transform that would break the working of group-by-page.

I know the result-transform and breadcrumb-view affects the result, yet I have no idea how the query works(prob copy paste from other genius). Hense I include the original code.

Removing result-transform/table-view/breadcrumb-show creates somewhat like my desired result. However I only want the page-name to the TODO block itself, without the entire parent block of TODO block. Hopefully I described a bit more clearly.

It’s probably mine when looking at the comments in the code :yum:
You need only remove the result-transform line actually.
The breadcrumb-show: false you need to keep. This will make sure the parent blocks don’t show.

Thanks for the original code btw, helps a lot!

To your reply, when removing breadcrumb-show, using the example above.
The output for multilevel blocks (see Mid-term Report block) would also show.

The following demonstration might explain clearer

# this is what it looks like
- Project A
    - Assignments:
        - DOING something

# What the desired output is:
- Project A
    - DOING something  #<- no need any parent block

# Basically I want the task block directly under page name
# - Pagename
#     - DOING/TODO tasks

Is it possible to achieve the above?

Just removing the result-transform line gives.

Aka this query.

{
    	:title [:b "Current Tasks"]
    	:query [:find (pull ?b [*])
                :where
                	[?b :block/marker ?marker]
                	[(contains? #{"DOING"} ?marker)]  ; TODO put in a value list with LATER.
					[?h :block/page ?p]
                ]
    	:table-view? false
		:breadcrumb-show? false  ; don't show the parent blocks in the result !important, due to result-transform the grouping is lost, and so you will be left with a simple list of TODO items. having those parents blocks mixed in may make the list more confusing. (setting this to true won't show the page btw!)
    	:collapsed? false
	}

Is this not what you are looking for?

Exactly! You are the real hero!

1 Like