NEXT query does not read scheduled and due dates
Describe the bug Tasks with keywoards TODO/NOW/LATER that have a scheduled or due date between tomorrow and the next 6 days do not show in the NEXT section in today's journal page.
To Reproduce Steps to reproduce the behavior:
- create a LATER task
- Schedule it to tomorrow
- Go to today's journal page
- See nothing (there is not NEXT section)
Expected behavior The task is listed under the NEXT section in today's journal page.
Desktop (please complete the following information):
- OS: MacOS
- Browser: Desktop application
- Version: 0.5.6
It seems that the NOW and NEXT sections only show tasks that either (1) stem from a journal page in the past 14 days (NOW) or next 7 days (NEXT), or (2) contain a reference to said journal page. However, they do not work with the normal SCHEDULED and DEADLINE functionality. It appears to me that these are two features that are unrelated to each other and stem from different ideas/versions of how tasks conceptually should work in Logseq.
I updated the query in the config.edn file so the first query returns all the tasks:
{:title "🔨 Tasks"
:query [:find (pull ?h [*])
:in $ ?start ?today
:where
[?h :block/marker ?marker]
[(contains? #{"NOW" "DOING" "LATER" "TODO"} ?marker)]
[?h :block/page ?p]
[?p :block/journal? true]
[?p :block/journal-day ?d]
[(>= ?d ?start)]
[(<= ?d ?today)]]
:inputs [:14d :today]
:result-transform (fn [result]
(sort-by (fn [h]
(get h :block/priority "Z")) result))
:collapsed? false}
I also found the default behavior to be unexpected. I'll happily open a PR to address this if we can get input on whether this is a bug or intentional feature.
Would be great to have the NEXT feature functional. As a new user, I tried reformatting my dates and TODOs, looking at the query to sort out what I was doing wrong, to no avail.
I'm also having trouble with the default NEXT query, which doesn't show a TODO that's coming up in 3 days.
How to make anything appear in the NEXT query? I can't understand it and an example would help a lot.
I have an updated version of the next query, which selects a lot more tasks. I also added some inline commenting for understanding. Maybe this is something to put in the config template?
{:title "📅 NEXT"
:query [:find (pull ?h [*]) ;get full block results
:in $ ?start ?next ;variables made from the values in :inputs to use in the query.
:where
[?h :block/marker ?marker] ;tasks are identified by having a marker like TODO
[(contains? #{"NOW" "LATER" "TODO"} ?marker)] ;specify which marker to include.
(or
[?h :block/page ?p] ;either the task is on a (journal) page
[?h :block/refs ?p] ;or references a (journal) page
)
;This will always be true as all blocks are on some page and tasks always reference a page, namely the default marker page i.e. TODO etc.
(or
[?p :block/journal-day ?d] ;the page is a journal page with date ?d
[?h :block/scheduled ?d] ;or the task is scheduled for date ?d
[?h :block/deadline ?d] ;or the task has a deadline for date ?d
)
[(> ?d ?start)] ;the date is bigger than ?start i.e. today
[(< ?d ?next)]] ;the date is smaller than ?next i.e. 7 days after today.
:inputs [:today :+7d] ;dynamic input to define start and next. In this case today and +7 days from today.
:group-by-page? false ;don't group the blocks by page (change to true to group)
:breadcrumb-show? true ;do show the parent block hierarchy of the block (change to false to hide it)
:collapsed? false} ;don't collapse the query to title only. Change to true to collapse the query.
@Siferiax Looks good. Looking for feedback from other participants in this thread.
Feel free to make it to a PR when it's ready.
Any updates?
Would love to see this, found this issue because of how unintuitive it felt.
This does not fix the problem, but I want to note that the "DOING" marker is not currently included in the query (nor in the suggested code from May), and I suspect that it should be. So if someone does fix this, please include that, unless there is some reason I don't know about why it should not be included.
Also I'd be happy to test the code above, including what I said about the DOING marker. Though it would help me if there were a user story describe what exactly the NEXT query should do.
This does not fix the problem, but I want to note that the "DOING" marker is not currently included in the query (nor in the suggested code from May), and I suspect that it should be. So if someone does fix this, please include that, unless there is some reason I don't know about why it should not be included.
It shows up through the NOW query actually. Check out the enhancement I made. I also rewrote the comment in the config for it. The question is more why NOW is part of the NEXT query honestly 😂 cause that one is in both. So it's a good point. But I think NOW should be removed. This way the NOW query shows tasks that are ongoing (NOW or DOING) and the NEXT query shows tasks to do at another time (LATER or TODO).
@Siferiax I am trying out your NEXT query now and it looks good. And FWIW, tasks marked DOING are not included in this query's results, where tasks marked NOW definitely are (maybe your enhancement is somewhere I have not looked). Personally, I don't mind taking NOW out of the NEXT query, as you suggest.
Here is how my config.edn looks like. It retrieves the "NEXT" after "NOW" and includes all tasks left out for the last year so they don't fall through the cracks. It also shows them in a more compact way and skips mentioning "TASKS" or whatever main block they were under for a tidier look.
{:journals
[{:title "🔨 Now"
:query [:find (pull ?h [*])
:in $ ?start ?today
:where
[?h :block/marker ?marker]
[(contains? #{"NOW" "DOING"} ?marker)]
[?h :block/page ?p]
[?p :block/journal? true]
[?p :block/journal-day ?d]
[(>= ?d ?start)]
[(<= ?d ?today)]]
:inputs [:14d :today]
:result-transform (fn [result]
(sort-by (fn [h]
(get h :block/priority "Z")) result))
:group-by-page? false
:collapsed? false}
{:title "📅 NEXT"
:query [:find (pull ?h [*])
:in $ ?start ?next
:where
[?h :block/marker ?marker]
[(contains? #{"NOW" "LATER" "TODO"} ?marker)]
[?h :block/page ?p]
[?p :block/journal? true]
[?p :block/journal-day ?d]
[(>= ?d ?start)]
[(<= ?d ?next)]]
:inputs [:365d :+7d]
:result-transform (fn [result]
(sort-by (fn [h]
(get h :block/priority "Z")) result))
:group-by-page? false
:breadcrumb-show? false
:collapsed? false}]}