Exclude tasks that are done

Hi,

I have this query, that shows me things that are relevant in the next 7 days:

#+ BEGIN QUERY
{:title "📥 week"
    :query [:find (pull ?b [*])
            :in $ ?start ?next
            :where
            (or
              [?b :block/scheduled ?d]
              [?b :block/deadline ?d])
            [(> ?d ?start)]
            [(< ?d ?next)]
    ]
    :inputs [:today :7d-after]
    :collapsed? true}
#+END_QUERY

How do I modify this query, that it excludes tasks that are already done ?

Thanks for your help in advance.

You can find the answer in this post. Should really read the rest of that thread.

Thanks for the hint, but it doesn’t seem to contain a solution for my case.

Maybe it makes sense to explain a bit more, what I try to achieve.

I have blocks that are scheduled (or have a deadline) that are not marked as task.
This shows me certain pieces of information when they are relevant.
These blocks show up in my query as expected.

On top I have scheduled tasks.
These show up wheter they are done or not.

But in my case, I only want to see scheduled blocks (or blocks with dealines) and scheduled tasks that are not done yet. And all this in the context of the next 7 days.

  • Indeed I am not sure that I understand your description.
  • Anyway, this is your exact query from above, with the linked condition added right below where:
    #+BEGIN_QUERY
    {:title "📥 week"
        :query [:find (pull ?b [*])
                :in $ ?start ?next
                :where
                [?b :block/uuid]
                (not [?b :block/marker "DONE"])
                (or
                  [?b :block/scheduled ?d]
                  [?b :block/deadline ?d])
                [(> ?d ?start)]
                [(< ?d ?next)]
        ]
        :inputs [:today :7d-after]
        :collapsed? true}
    #+END_QUERY
    

That’s not exactly the final solution.

This assumes that all blocks with a scheduled or deadline date have a marker.
But they don’t. Only tasks have a marker, but I’m using scheduled dates oder deadline dates also for blocks, that only contain text and and no marker.

So the query needs to handle blocks with and without markers.

How to tell whether a non-task block is done or not?

I use this feature to show me relevant information at a certain time.
Things I need to keep in mind or pay attention to.

This is not necessary coupled to an action that needs to be done in the sense of a task.

And how is it indicated when such a non-task is done, and therefore it should be excluded?

A non-task is never done.
But its date (scheduled or deadline) is out of the scope of the query.
Basically everything that is scheduled (or has a deadline) defined as yesterday or older, is never shown again.

I have a separate query for overdue tasks. So these will not slip through.

The used condition [(> ?d ?start)] already excludes everything that is for yesterday or older. So what is missing? Could you provide an example block that appears in the results, while it shouldn’t?

I have tried to provide some examples, what the query should show and what not.
The examples are with scheduled dates, but I should also work with deadlines.

Basically the query works as expected.
Only the case 4 (Task scheduled for tomorrow, done) is not filtered out yet.

With the above query (edited in order to not throw errors, and of course expanded), this is what I get:


Case 4 is filtered out.

That’s exactly what I needed.

Thanks a lot mate !!