zdbski
June 23, 2023, 8:09am
1
What is the best practice for listing all jobs at the same level as the query,
and all jobs below the query but not higher?
ps.
I using
[?block :block/parent ?parent]
[?parent :block/content "v23-05"]
But this element only shows tasks nested on bullet v23-05, but not lower.
So I’ll modify the query from
If you indent the query in it, you can run it based on it’s parent block as input.
So for example:
- parent block title
- meeting notes
- stuff
- query
Or make meeting notes the parent, whatever you prefer.
You can then use this as the query:
#+BEGIN_QUERY
{:title ["Query by page & alias"]
:query [:find (pull ?b [*])
:in $ ?parent %
:where
[?b :block/marker "TODO"]
(check-parent ?parent ?b)
]
:rules [
[(check-parent ?parent ?b)
[?b :block/parent ?parent…
To search down instead of up
#+BEGIN_QUERY
{:title ["Find child blocks"]
:query [:find (pull ?child [*])
:in $ %
:where
[?parent :block/content "v23-05"]
(get-children ?parent ?child)
; Add any ?child block filtering here.
]
:rules [
[(get-children ?parent ?child)
[?child :block/parent ?parent]
]
[(get-children ?parent ?child)
[?t :block/parent ?parent]
(get-children ?t ?child)
]
]
}
#+END_QUERY
If you need help with any specific filters let me know!
1 Like
zdbski
June 26, 2023, 10:47am
3
Thank you !
#1 I see that if I have bullet point parent name 23-05
not working, but if I have 23 05
working, why?
#2
How can I change this query to search not only in the document where it is located, but in all documents? Because at the moment it is only working in the document where it is located.
#3 I added
[?parent :block/content "v23 05"]
(get-children ?parent ?child)
; Add any ?child block filtering here.
[?b :block/marker "TODO"]
]
But not show only bullet with TODO
Might be it is not the content of the block actually.
As demonstrated:
You do not see the actual difference here.
But the second one has the hidden property collapsed:: true
which may linger unseen.
To mitigate this issue and make it more flexible anyway.
We can change [?parent :block/content "23-05"]
To
[?parent :block/content ?c]
[(clojure.string/includes? ?c "23-05")]
Do be mindful that any block with more than just 23-05 will be selected here.
It could be that it needs to be clojure.string/starts-with?
or clojure.string/end-with?
. I don’t know your data.
It should work everywhere already.
?b
is not defined.
It should be [?child :block/marker "TODO"]
zdbski
June 28, 2023, 1:04pm
5
@Siferiax thank you!
At the moment I use
#+BEGIN_QUERY
{:title ["TASK ONLY FROM PARENT"]
:query [:find (pull ?child [*])
:in $ %
:where
[?parent :block/content ?c]
[(clojure.string/includes? ?c "v23 05")]
(get-children ?parent ?child)
[?child :block/content ?blockcontent]
(not [(clojure.string/includes? ?blockcontent "DONE")])
(or [(clojure.string/includes? ?blockcontent "TODO")]
[(clojure.string/includes? ?blockcontent "DOING")]
[(clojure.string/includes? ?blockcontent "WAITING")]
[(clojure.string/includes? ?blockcontent "LATER")]
[(clojure.string/includes? ?blockcontent "NOW")])
; Add any ?child block filtering here.
]
:rules [
[(get-children ?parent ?child)
[?child :block/parent ?parent]
]
[(get-children ?parent ?child)
[?t :block/parent ?parent]
(get-children ?t ?child)
]
]
:result-transform (fn [result]
(reverse (sort-by (juxt (fn [i] (get i :block/scheduled)) (fn [h] (get h :block/priority "Z"))) result)))
:breadcrumb-show? false
:collapsed? false
}
#+END_QUERY
At the moment, the tasks are sorted:
Task from 2023-06-30
Task from 2023-06-20
Other task without date
I want them sorted like this:
Task from 2023-06-20
Task from 2023-06-30
Other task without date
How can I do that? Additionally, where can I learn more about advanced query, etc.? What are the best sources?
Why not use :block/marker
?
Instead of
(not [(clojure.string/includes? ?blockcontent "DONE")])
(or [(clojure.string/includes? ?blockcontent "TODO")]
[(clojure.string/includes? ?blockcontent "DOING")]
[(clojure.string/includes? ?blockcontent "WAITING")]
[(clojure.string/includes? ?blockcontent "LATER")]
[(clojure.string/includes? ?blockcontent "NOW")])
Use
[?child :block/marker ?m]
[(!= ?m "DONE")]
As for the sorting.
:result-transform (fn [result]
(sort-by (juxt (fn [i] (get i :block/scheduled)) (fn [h] (get h :block/priority "Z"))) result))
And resources.
https://docs.logseq.com/#/page/advanced%20queries
At the bottom is a section with additional links as well.
zdbski
June 29, 2023, 8:55am
7
@Siferiax thanks!
I have one last question:
When I have set up
:result-transform (fn [result]
(sort-by ( juxt(fn [i] (get i :block/scheduled)) (fn [h] (get h :block/priority "Z"))) result))```
When I remove `juxtapose`,
:result-transform (fn [result]
(sort-by ( juxt(fn [i] (get i :block/scheduled)) (fn [h] (get h :block/priority "Z"))) result))
Why isn’t the first task sorted with 06-29, followed by 06-30, and the rest without a date? At the moment, there is a task with 06-29, one without a date, one with 06-30, and the others.
Can I set the bullet points to be collapsed, like in the screenshot on the left?
zdbski
June 30, 2023, 10:33am
8
@Siferiax , can you show me how to achieve these two points?
Please don’t be rude by tagging me again because I didn’t respond within 24 hours.
I’m not your personal helpdesk.
1 Like