Exclude future journal pages

So I’ll be pulling from this topic for the answer:

A few queries down in the first post we have “Open unplanned tasks from journal pages”.
There we have something for journal pages. It also happens to have today in it.
Only it has scheduled, we don’t need that.

So we modify the query a little bit to get (I’ve also updated it for how I write queries today :P):

#+BEGIN_QUERY
{:title [:h3 "☑ Tasks"]
 :inputs [:today]
 :query [:find (pull ?b [*])
 :in $ ?day
 :where
  [?p :block/journal-day ?d]  ; ?p has the attribute journal-day with value ?d (you don't need the :block/journal? attribute if you also use this one)
  [(<= ?d ?day)] ; the value of ?d needs to be before or on ?day (today that is)
  [?b :block/page ?p]  ; ?b has the attribute :block/page with value ?p, ?p has been define with the identifier of a journal page above.
  [?b :block/marker "TODO"] ; ?b is a task marked as TODO.
 ]
 :breadcrumb-show? false
 :result-transform (fn [result] (sort-by (fn [r] (get-in r [:block/page :block/journal-day])) result))  ; Sort by the journal date
}
#+END_QUERY
2 Likes