Creating a query for overdue tasks

Hi,
I have a tasks page (Taakjes) which has a list of recurring tasks in it. These have a scheduled property and are set to repeat in daily, weekly or monthly intervals.
What I’m trying to do is get a list of open tasks, specifically those that have a schedule date that is now in the past.

At first I ran into the issue that the tasks are not in the journal pages and the between query only looks at the journal page dates.
But now I run into the issue that it isn’t pulling tasks with a schedule date in the past.

Here’s the query I have so far, mainly altered a query from the advanced queries documentation page.

#+BEGIN_QUERY
{:title “overdue scheduled tasks”
:query [:find (pull ?block [*])
:in $ ?start ?next
:where
[?block :block/scheduled ?d]
[(> ?d ?start)]
[(< ?d ?next)]]
:inputs [:30d :1d-after]
:collapsed? false}
#+END_QUERY

It successfully pulls tasks from the Taakjes page and not just the journal pages. But it only pulls tasks that are scheduled for today. Not those in the past.

So is what I want even possible?
Any suggestions of what I’m doing wrong, or else maybe a workaround?

I was being an idiot and figured out my dates for the tasks were incorrect! So it already does what I want in the journal pages automatically and the query I already had also works just fine :slight_smile:

1 Like

Hello. I like it like this:

   {:title " Overdue"
    :query [:find (pull ?b [*])
          :in $ ?yesterday
          :where
            [?b :block/marker ?m]
            [(contains? #{"TODO" "DOING" "WAITING"} ?m)]
            [?b :block/page ?p]
            [?p :block/journal? true]
            [?p :block/journal-day ?d]
            [(<= ?d ?yesterday)]]
    :inputs [:yesterday]
    :result-transform (fn [result]
      (sort-by (fn [h]
            (get h :block/marker))
            result))
    :breadcrumb-show? false
    :group-by-page? true
    :collapsed? false
   }

But I’d also like for “((embedded))” TODOs to be included… Anybody solved it? :slight_smile:

What does embedded mean for you?
Is it something to solve with a recursive search?

So tasks as:

- some text #some-tag
  - TODO XYZ

Then perhaps this thread is what you mean?

Otherwise please explain further what you are looking for :slight_smile:

PS. Also funny to see my own old post… I was so unaware of stuff back then :heart:

1 Like

No I mean the embedded ones shown here under cowboy don’t show up, whereas the regular ones under plan do:

– The blocks with markers I’ve brought as embedded references (?) to the journal, using the ((uuid)) syntax to reference a block in /pages (as opposed to /journal).

Perhaps both this and that can be solved by or-join ?

Oh! Yes I know what you mean now :slight_smile:
I do have a solution for that…
It is indeed an or-join.

(or-join [?b ?p]
  [?b :block/page ?p]
  (and
    [?e :block/refs ?b]
    [?e :block/page ?p]
  )
)
1 Like