-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Unable to use both built-in rules and custom rules at the same time in default queries #7201
Description
What happened?
Some context: I've learned you can use the simple queries helpers in your queries. i.e. this works:
{:title "TODO"
:query [:find (pull ?h [*])
:in $
:where
(task ?h #{"NOW" "LATER" "TODO"})]I've been trying to make an "actionable" default query that grabs all the tasks that are respecting the following rules:
- Are TODO | DOING
- Are one of the following:
- scheduled and $today > scheduled
- not scheduled
After watching https://www.youtube.com/watch?v=bAilFQdaiHk&feature=emb_imp_woyt, it seemed like rules was the way to go here. Since I could use the implicit OR behaviour by having two rules with the same name:
- one for scheduled and $today > scheduled
- one for not scheduled
I've managed to make the following work:
{:title "ACTIONABLE"
:query [:find (pull ?h [*])
:in $ ?today %
:where
(is-task-with-status ?h #{"NOW" "LATER" "TODO"})
(is-available ?h ?today)]
:inputs [:today]
:rules
[[(is-task-with-status ?h ?markers)
[?h :block/marker ?marker]
[(contains? ?markers ?marker)]]
[(is-available ?x ?now)
[?x :block/scheduled ?scheduled]
[(>= ?now ?scheduled)]]
[(is-available ?x ?now)
[(get-else $ ?x :block/scheduled :no-value) ?v]
[(= ?v :no-value)]]]
:collapsed? true}But, you'll note that I had to rewrite the task rule here. For some reason the simple query rule task isn't merged with my custom rules.
i.e. this didn't work:
{:title "ACTIONABLE"
:query [:find (pull ?h [*])
:in $ ?today %
:where
(task ?h #{"NOW" "LATER" "TODO"})
(is-available ?h ?today)]
:inputs [:today]
:rules
[[(is-available ?x ?now)
[?x :block/scheduled ?scheduled]
[(>= ?now ?scheduled)]]
[(is-available ?x ?now)
[(get-else $ ?x :block/scheduled :no-value) ?v]
[(= ?v :no-value)]]]
:collapsed? true}Reproduce the Bug
- Add the following default query to your config.edn:
{:title "ACTIONABLE"
:query [:find (pull ?h [*])
:in $ ?today %
:where
(task ?h #{"NOW" "LATER" "TODO"})
(is-available ?h ?today)]
:inputs [:today]
:rules
[[(is-available ?x ?now)
[?x :block/scheduled ?scheduled]
[(>= ?now ?scheduled)]]
[(is-available ?x ?now)
[(get-else $ ?x :block/scheduled :no-value) ?v]
[(= ?v :no-value)]]]
:collapsed? true}The query fails and reports an error about :today not confirming to the conj protocol.
If I change :in $ ?today % to :in $ ?today, a different error appears and it says Unknown rule 'is-actionable in ...
Expected Behavior
The task rule is merged into the custom rules.
Screenshots
Desktop Platform Information
MacOS 12.6, App, Logseq 0.8.10
Mobile Platform Information
No response
Additional Context
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status

