logseq icon indicating copy to clipboard operation
logseq copied to clipboard

NEXT query does not read scheduled and due dates

Open fladd opened this issue 4 years ago • 15 comments

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:

  1. create a LATER task
  2. Schedule it to tomorrow
  3. Go to today's journal page
  4. 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

fladd avatar Jan 02 '22 21:01 fladd

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.

fladd avatar Jan 02 '22 22:01 fladd

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}

jaydeland avatar Jan 12 '22 18:01 jaydeland

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.

joeltaylor avatar Mar 19 '22 21:03 joeltaylor

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.

buffalovision avatar Apr 11 '22 17:04 buffalovision

I'm also having trouble with the default NEXT query, which doesn't show a TODO that's coming up in 3 days.

life5ign avatar Aug 23 '22 06:08 life5ign

How to make anything appear in the NEXT query? I can't understand it and an example would help a lot.

cemsbr avatar Apr 11 '23 02:04 cemsbr

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.

Screenshot_20230521-194145

Screenshot_20230521-194203

Siferiax avatar May 21 '23 17:05 Siferiax

@Siferiax Looks good. Looking for feedback from other participants in this thread.

Feel free to make it to a PR when it's ready.

cnrpman avatar May 22 '23 09:05 cnrpman

Any updates?

hezhizhen avatar Jun 12 '23 02:06 hezhizhen

Would love to see this, found this issue because of how unintuitive it felt.

skspade avatar Aug 14 '23 21:08 skspade

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.

MegaKeegMan avatar Dec 17 '23 01:12 MegaKeegMan

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.

MegaKeegMan avatar Dec 17 '23 01:12 MegaKeegMan

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 avatar Dec 17 '23 07:12 Siferiax

@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.

MegaKeegMan avatar Dec 17 '23 17:12 MegaKeegMan

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}]}

cosmopotamian avatar Aug 21 '24 21:08 cosmopotamian