uwe
June 30, 2023, 11:14am
1
Hello
Following query Lists all todos of the next 42 days in my journal. But the order does not fit, because the todo with the farthest deadline is at the first place and the closest todo is at the last place. What do I have to do, that the order is the other way round?
This is the current query:
(get h :block/priority “Z”)) result))
:collapsed? false}
{:title “ NEXT”
:query [:find (pull ?h [*])
:in $ ?start ?next
:where
[?h :block/marker ?marker]
[(contains? #{“NOW” “LATER” “TODO”} ?marker)]
[?h :block/ref-pages ?p]
[?p :block/journal? true]
[?p :block/journal-day ?d]
[(> ?d ?start)]
[(< ?d ?next)]]
:inputs [:today :42d-after]
:collapsed? false}]}
Thanks
uwe
Please refer to this topic for sorting based on deadline:
Sorting by scheduled date:
#+BEGIN_QUERY
{:title [" near TODOs (next 7 days, scheduled or deadline)"]
:query [:find (pull ?b [*])
:in $ ?start ?next
:where
(or
[?b :block/scheduled ?d]
[?b :block/deadline ?d]
)
[(>= ?d ?start)]
[(<= ?d ?next)]
]
:result-transform (fn [result] (sort-by (fn [d] (get d :block/scheduled) ) result))
:inputs [:today :7d-after]
:collapsed? false}
#+END_QUERY
Sorting by …
Let me know if you need more help!
uwe
July 4, 2023, 5:30am
3
Hello Siferiax,
Thanks for your help. With your examples i was able to fix the Problem. I used the following query:
(get h :block/priority “Z”)) result))
:collapsed? false}
{:title “ NEXT”
:query [:find (pull ?h [*])
:in $ ?start ?next
:where
[?h :block/marker ?marker]
[(contains? #{“NOW” “LATER” “TODO”} ?marker)]
[?h :block/ref-pages ?p]
[?p :block/journal? true]
[?p :block/journal-day ?d]
[(> ?d ?start)]
[(< ?d ?next)]]
:result-transform (fn [result]
(sort-by (fn [h]
(get-in h [:block/page :block/journal-day]))
result))
:inputs [:today :42d-after]
:collapsed? false}]}
uwe
1 Like