Hi all,
Since I am fairly new to Logseq and currently diving deep into advanced queries and templates,
I am wondering how to get the properties of the most-left block or in other words getting the main parent.
The main goal I want to achieve is to build a meeting template, which embeds a query for all the doings/markers assigned to some dedicated person.
As of now I am assigning meeting attendees with the block property participants
beneath the main block. I need to access this property to make a proper comparison.
I put a sample down bellow, the used query is not finished yet:
As far as I know, there is currently no field like :block/main-parent
in the DB schema, which would definitely help.
The current query is as follows:
{
:title [:h4 "Find all DOINGs based on current assigned participant"]
:query [
:find (pull ?b [*])
:where
[?b :block/marker ?m]
[(contains? #{"TODO"} ?m)]
]
}
I am also open to different approaches like tagging each individual TODO block with a tag, but what’s the best option to assign tasks to people in a meeting?
Best regards
Welcome. For e.g. person @Chloe
, try something like this:
{
:title [:h4 "Find all DOINGs based on current assigned participant"]
:query [
:find (pull ?b [*])
:in $ ?participant %
:where
[?b :block/marker ?m]
[(contains? #{"TODO"} ?m)]
(ancestor ?a ?b)
[?a :block/properties ?props]
[(get ?props :participants) ?participants]
[(contains? ?participants ?participant)]
]
:inputs [
"@Chloe"
[
[
[ancestor ?a ?b]
[?b :block/parent ?a]
]
[
[ancestor ?a ?b]
[?parent :block/parent ?a]
(ancestor ?parent ?b)
]
]
]
}
2 Likes
On second thought, you may prefer a simpler way:
{
:title [:h4 "Find all DOINGs based on current assigned participant"]
:query [
:find (pull ?b [*])
:in $ ?participant-name
:where
[?participant :block/original-name ?participant-name]
[?b :block/marker ?m]
[(contains? #{"TODO"} ?m)]
[?b :block/path-refs ?participant]
]
:inputs ["@Chloe"]
}
1 Like
I think this misses the property from your first query.
If I look at @Sofa1780 their screenshots their current query returns an entry in the journal.
Which this query will suffer from also.
Recurring searching is probably required.
Can always put that in a rules sections instead of input so the query is a little more clear.
Like so:
{
:title [:h4 "Find all DOINGs based on current assigned participant"]
:query [
:find (pull ?b [*])
:in $ ?participant %
:where
[?b :block/marker ?m]
[(contains? #{"TODO"} ?m)]
(ancestor ?a ?b)
[?a :block/properties ?props]
[(get ?props :participants) ?participants]
[(contains? ?participants ?participant)]
]
:inputs ["@Chloe"]
:rules [
[(ancestor ?a ?b)
[?b :block/parent ?a]
]
[(ancestor ?a ?b)
[?parent :block/parent ?a]
(ancestor ?parent ?b)
]
]
}
1 Like
Hi @mentaloid,
Hi @Siferiax,
thank you both really really much for your input!
I am much closer to the final query now, though I don’t understand the rules mechanism not yet.
According to my use case the input basically is depicted by the current block property participants
With the query you both mentioned the query will show all TODOs where Chloe is mentioned as a participant:
What I am searching for is a query which relates to the current block mentioned participants.
I will try to figure this out tomorrow and will hopefully gain some results. ![:slight_smile: :slight_smile:](https://discuss.logseq.com/images/emoji/twitter/slight_smile.png?v=12)
In the meantime, do you know where I can find some more information about the mentioned rules-mechanism?
I am really looking forward to get a deeper understanding.
Best regards!
For the rules-mechanism, read the reference.
1 Like