New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance: Add :remove-block-children? query option for advanced queries and an advanced query :template fix #9229
Conversation
(db/custom-query-result-transform query-result remove-blocks q)) | ||
(cond-> (db/custom-query-result-transform query-result remove-blocks q) | ||
(get q :remove-block-children? true) | ||
tree/filter-top-level-blocks)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tree filtering was moved here because modifying results outside of get-query-result
results in the query counts being wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QAed and works as described!
I made a minor change to apply only tree/filter-top-level-blocks
when the query results are blocks, so the blocks count and other queries that return non-blocks don't have to include :remove-block-children: false
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, work as expected.
There are cases where we want to see block children e.g. using the :current-block input. Still kept the existing behavior as most users probably still want children removed. Also fix result count when removing children
fff3f71
to
f0dbcf7
Compare
Makes sense |
@logseq-cldwalker is it a way now to position result on the same line as title? I've tryed to use view, but result appears only on the second line: #+BEGIN_QUERY
{:title "Count under current block"
:inputs [:current-block]
:query [:find (count ?b)
:in $ ?current-block
:where [?b :block/parent ?current-block]]
:view (fn [count] count)
:remove-block-children? false}
#+END_QUERY |
Hi. :title and :view query options are unrelated to this PR. This PR allows
that query to return correct results. Having those two query options give
you a desired display sounds like a feature request for the forum
…On Tue, 25 Apr 2023 at 17:16, Sergey Kolesnik ***@***.***> wrote:
@logseq-cldwalker <https://github.com/logseq-cldwalker> is it a way now
to position result on the same line as title?
I've tryed to use view, but result appears only on the second line:
#+BEGIN_QUERY
{:title "Count under current block"
:inputs [:current-block]
:query [:find (count ?b)
:in $ ?current-block
:where [?b :block/parent ?current-block]]
:view (fn [count] count)
:remove-block-children? false}
#+END_QUERY
<https://user-images.githubusercontent.com/1984175/234405620-4f5f5466-7e87-4fde-9fd8-53af8d96358d.png>
—
Reply to this email directly, view it on GitHub
<#9229 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AXFVC55Q7RR6KBOUOJDVCY3XDA5JJANCNFSM6AAAAAAXKEXUXY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
This PR adds an option to make removing block children optional for a query and fixes bugs #3260 and #9045. The query option
:remove-block-children?
is added because there are times when we want to see block children e.g. when using the :current-block input. I still left children removal as the default as most users probably want the parent block when doing tag/page-ref searches e.g. #6406. To QA this option, try:The second commit removes the removal of template blocks as it prevents using from querying their template blocks e.g. #3260.