I have the query below, which finds all open tasks scheduled for today, or with status NOW, and sorts them all by scheduled date ascending. How do I add to the query to put all tasks with priority A on the top of the list (sorted by scheduled date ascending), with all tasks with no priority beneath that (sorted by scheduled date ascending)?
Can you explain what the ->> and coll thing is indented to do? I really love loqseq but datomic must be trying to win some kind of championship in worst documented thing of all time. The search on datomic.com fills me with rage, how can someone manifest something this obtuse?
I don’t think that the sort-by in this case is the clojure sort-by, which has a composable signature. If it was, my solution above would not work. I think that the sort-by here being called here is from the Logseq DSL, maybe this stuff, not well versed enough in Clojure to understand.
These technologies are promising is many ways and there are things that appeal to me philosophically but the tooling and docs around all of this is absolutely awful.
Rather than using juxt and having to pass in multiple functions to get a vector of the results back, you could just use a single function that returns a vector directly:
(sort-by (fn [r] [(get r :block/deadline) (get r :block/priority "Z")]) result)
Hey there, I tried using your query to get my tasks filtered by deadline, then by scheduled date and finaly by priority. My understanding is that the tasks with the same deadline are then sorted by scheduled, and if the scheduled date is the same, it’ll be by priority and so on.
Here is my query :
#+BEGIN_QUERY
{:title [:h3 "🔨 Now"]
:query [:find (pull ?b [*])
:where
[?b :block/marker ?marker]
[(contains? #{"DOING" "NOW"} ?marker)] ; Check if the marker is either "DOING" or "NOW"
]
:table-view? false
:breadcrumb-show? false ; Don't show the parent blocks in the result
:result-transform (fn [result]
(sort-by
(fn [r]
[
(get-in r [:block/deadline] "9999-12-31")
(get-in r [:block/scheduled] "9999-12-31")
(get-in r [:block/priority] "Z")
]
) result)) ; Sort the result by the deadline date, then scheduled date and then by priority
}
#+END_QUERY
What I don’t get is why are my scheduled task not sorted correctly ? The second and third task don’t have any deadline, hence they should be sorted by scheduled date, but it is not the case.
Thanks a lot, it was indeed the fix ! I did not think about it at all, even though it was stated here.
Here is the corrected script with multiple sort orders :
#+BEGIN_QUERY
{:title [:h3 "🔨 Now"]
:query [:find (pull ?b [*])
:where
[?b :block/marker ?marker]
[(contains? #{"DOING" "NOW"} ?marker)] ; Check if the marker is either "DOING" or "NOW"
]
:table-view? false
:breadcrumb-show? false ; Don't show the parent blocks in the result
:result-transform (fn [result]
(sort-by
(fn [r]
[
(get-in r [:block/deadline] 99991231)
(get-in r [:block/scheduled] 99991231)
(get-in r [:block/priority] "Z")
]
) result)) ; Sort the result by the deadline date, then scheduled date and then by priority
}
#+END_QUERY