Strage Behaviour: Exclude all Tasks linked to Pages Having Property Status

I have Few Project Pages. Wanted a query which lists Tasks linked to Non Project Page.

In example both “curate” and “minimalism” are non Project Pages.

However the query Below only Lists “Todo 1” from curate but “Test Mini” is not listed until i remove the clause to exclude, pages with property.

#+BEGIN_QUERY
{:title [:h3 "⚓ Projectless"]
:query [:find (pull ?b [*])
       :where
       [?b :block/path-refs ?p]
       (task ?b #{"LATER" "TODO"})
       (not [?b :block/scheduled])
       (not [?b :block/deadline])
       [?p :page/properties ?prop]
       (not [(get ?prop :status) ?s])
 ]
}
#+END_QUERY

Strangely Page Minimalism has no Page Property but still is getting filtered.

Debug Details

Removing Property Match Clauses make results appear.

       [?p :page/properties ?prop]
       (not [(get ?prop :status) ?s])

Block Info

{:block/uuid #uuid "6534b7f3-f557-4a0f-8fac-43031535b3fd",
 :block/left {:db/id 93},
 :block/refs [{:db/id 4}],
 :block/format :markdown,
 :block/content "TODO Todo 1",
 :db/id 90,
 :block/path-refs [{:db/id 4} {:db/id 88} {:db/id 89}],
 :block/parent {:db/id 93},
 :block/page {:db/id 89}, 
 :block/marker "TODO"}
{:block/uuid #uuid "6534b7f3-c4b8-4f90-80ef-5bcf14298ad0",
 :block/left {:db/id 91},
 :block/refs [{:db/id 4}],
 :block/format :markdown,
 :block/content
 "TODO Test Mini\n:LOGBOOK:\nCLOCK: [2023-10-22 Sun 11:05:24]--[2023-10-22 Sun 11:05:27] =>  00:00:03\n:END:",
 :db/id 101,
 :block/path-refs [{:db/id 4} {:db/id 87} {:db/id 89}],
 :block/parent {:db/id 91},
 :block/page {:db/id 89}, 
 :block/marker "TODO"}

Page Info

Journal Page of Task Blocks

{:block/uuid #uuid "6534b7f3-dcc7-4bb6-b35f-12edf8e08511",
 :block/journal? true,
 :block/updated-at 1697954560845,
 :block/created-at 1697953779441,
 :block/journal-day 20231020,
 :db/id 89,
 :block/name "oct 20th, 2023",
 :block/file {:db/id 85}, 
 :block/original-name "Oct 20th, 2023"}

Minimalism Page

{:block/uuid #uuid "6534ba3b-4465-4cfd-a071-96c278cbd0bd",
 :block/journal? false,
 :block/updated-at 1697954284013,
 :block/created-at 1697953783983,
 :block/format :markdown,
 :db/id 87,
 :block/name "minimalism",
 :block/file {:db/id 14500}, 
 :block/original-name "Minimalism"}

TODO Page

{:db/id 4,
 :block/journal? false,
 :block/name "todo",
 :block/original-name "TODO",
 :block/uuid #uuid "6534ba3b-1b7b-4cba-87a2-d8725858abd8"}

Curate Page

{:block/properties-text-values {:exclude-from-graph-view "true"},
 :block/uuid #uuid "6534b80a-08ed-4922-b79e-51f22a76f05b",
 :block/properties {:exclude-from-graph-view true},
 :block/journal? false,
 :block/updated-at 1697953783739,
 :block/created-at 1697953783739,
 :db/id 88,
 :block/name "curate",
 :block/file {:db/id 13330}, 
 :block/original-name "curate"}

I found the cause but not able to Formulate the query.

  • curate Page has some properties but not Status.
  • Minimalism has no Properties, hence its not able to check Status.

If i add any Properties to Minimalism it starts appearing.

Hence i figured i need a query which shows Tasks with References

  • Having Properties without type as Status.
  • Having No Properties.

I tried this query which is able to meet above requirement but only for Type Staus “Ongoing”. I am unable to make it exclude pages of any Status Type. Any help is appreciated @Siferiax

#+BEGIN_QUERY
{:title "TODO's without Ongoing status"
 :query [:find (pull ?b [*])
         :where   
 [?b :block/marker "TODO"]
 [?b :block/page ?p]
 [?p :block/journal-day ?d]
 [?b :block/path-refs ?r]
(not (page-property ?r :status "Ongoing"))
]}

#+END_QUERY

From the top of my head remove Ongoing and keep the double quotes.
At least in my experience this gave me all results of the property instead of only the empty ones I was going for lol.

I tried that but unfortunately it doesn’t work. Instead it matches nothing hence all tasks are included via Not Clause.

:frowning:
Now an actually tested answer :heart:
Your first posted query actually also doesn’t work. It is the first query in my screenshot.

  • Page 3 has status:: Ongoing
  • Page 4 has status:: anything
  • Page 1 and 2 don’t have a status.

Second query:

#+BEGIN_QUERY
{:title "TODO's without Ongoing status"
 :query [:find (pull ?b [*])
         :where   
 [?b :block/marker "TODO"]
 [?b :block/page ?p]
 [?p :block/journal-day ?d]
 (not [?b :block/path-refs ?r]
 (page-property ?r :status ""))
]}
#+END_QUERY

Thanks a lot for trying it out and sharing the query. It works Perfectly.

I on myself could not have tried “not” clause on reference.

:grinning:

1 Like

A good general rule of thumb for not clauses is that if they don’t filter out what you want at all, then a clause outside of their bounds, should be within them.
As was the case here as well :slight_smile:

Thanks for the tip. Will keep in mind :slight_smile: