The problem is, it fetches the children of such tagged blocks into the pool which are all useless to me. If I only want the blocks with the tag but not their children, how should I write the query?
Thank you so much! I ended up with that query by sticking two other queries together without understanding what they do and I didn’t know schema.cljs has simple instructions inside. It’s a great resource!
Your query is perfect. I do want to see the children. I just don’t want the children & grandchildren to be in the pool and skew the probabilities^^
Wait, I noticed a problem. This query, when expanded, keeps executing itself as long as my cursor hovers over the query title, so it keeps blinking and giving me new results
In discord they replied to me that’s normal to have different quotes in different devices. But it’s not normal that the quote is changing continuously so probably a bug if the latest version
ohh I see what’s you’re asking. yes it’s normal. because this is a kind of “random number generator”, which when executed will give you a different result every time. When you open logseq on a different device, the query executes itself.
the result changing continuously because the query keeps executing itself when the cursor hovers over the “query title” line – I agree this is a bug.
So I just spent the past 5h fighting with gemini figuring out how to make deterministically random quotes. As in a journal should always have the same quote (as long as new quotes aren’t added)
#+BEGIN_QUERY
{:title [:h1 "Quote of the Day"]
:query [:find
?pageName
(pull ?b [*])
:in $ ?pageName
:where
[?b :block/page ?p]
[?b :block/refs ?t]
[?t :block/name "quote"]
]
:inputs [:query-page]
:result-transform (fn [result] (let [ _ 1
name (nth result 0)
numQuotes (-> result count (/ 2))
hashVal (hash name)
index (mod hashVal numQuotes)
quote (nth result (-> index (* 2) (+ 1)))
] [quote]))
:collapsed? false}
#+END_QUERY