Combining 2 advanced queries

I have 2 working queries that retrieve overdue tasks, one from the journal pages and one for scheduled task

{:title [:h2 "🧨 OVERDUE"]
 :query [:find (pull ?b [*])
         :in $ ?start ?end
         :where
         (task ?b #{"TODO" "DOING"})
         (between ?b ?start ?end)]
 :inputs     [:365d :today]
 :breadcrumb-show? true}

{:title [:h2 "🧨 OVERDUE"]
 :query [:find (pull ?b [*])
         :in $ ?start ?end
         :where
         (task ?b #{"TODO" "DOING"})
         (or  [?b :block/scheduled ?date]
              [?b :block/deadline ?date])
         [(> ?end ?date)]]
 :inputs     [:365d :today]
 :breadcrumb-show? true}

I wanted to combine the 2 together to get all overdue tasks but failed, please help me with this :pray:

{:title [:h2 "🧨 OVERDUE"]
 :query [:find (pull ?b [*])
         :in $ ?start ?end
         :where
         (task ?b #{"TODO" "DOING"})
         (or (between ?b ?start ?end) (and (or  [?b :block/scheduled ?date]
                                                [?b :block/deadline ?date])
                                           [(> ?end ?date)]))]
 :inputs     [:365d :today]
 :breadcrumb-show? true}
#+BEGIN_QUERY
{:title [:h2 "🧨 OVERDUE"]
  :query [:find (pull ?b [*])
         :in $ ?day
         :where
         [?b :block/marker ?marker]
         [(contains? #{"TODO" "DOING"} ?marker)]
         (or-join [?b ?d]
               [?b :block/scheduled ?d]
               [?b :block/deadline ?d]
               (and [?b :block/page ?p]
               [?p :block/journal-day ?d] 
          ))
          [(< ?d ?day)]
    ]
    :inputs [:today]
    :table-view? false
    :breadcrumb-show? true
    :collapsed? false
}
#+END_QUERY

Hopefully this works for you :slight_smile:
(Cross posting from discord)

1 Like