How do you automatically copy your todo's from yesterdays journal into today's journal?

I usually end up creating a bunch of TODO in my Journal during the day. I would like to begin my day with my journal not being blank but containing all the incomplete TODOs from all previous days. Is this possible?

unfinished business plugin

2 Likes

I’m using this template

#+BEGIN_QUERY
{:title "Journal Task Collection"
 :query [:find (pull ?b [*])
       :where
       [?b :block/marker ?marker]
       [(contains? #{"NOW" "DOING" "TODO"} ?marker)]
       [?b :block/page ?p]
       [?p :page/name ?pn]
         (   or  [?p :page/journal? true] 
          )
  ]
}
#+END_QUERY
3 Likes

Very nice! I will copy this, but use the “schedule-and-repeat-by-one” to have it appended (rather than inserted as a template)

#+BEGIN_QUERY
{:title "Journal Task Collection"
 :query [:find (pull ?b [*])
       :where
       [?b :block/marker ?marker]
       [(contains? #{"NOW" "DOING" "TODO"} ?marker)]
       [?b :block/page ?p]
       [?p :page/name ?pn]
         (   or  [?p :page/journal? true] 
          )
  ]
}
#+END_QUERY
SCHEDULED: <2022-05-21 Sat .+1d>

I added/modified the following section of my config.edn to show incomplete, overdue, and upcoming tasks from my prior journals:

:default-queries
 {:journals
  [{:title            "🔨 NOW"
    :query            [:find (pull ?h [*])
                       :in $ ?start ?today
                       :where
                       [?h :block/marker ?marker]
                       [(contains? #{"NOW" "DOING"} ?marker)]
                       [?h :block/page ?p]
                       [?p :block/journal? true]
                       [?p :block/journal-day ?d]
                       [(>= ?d ?start)]
                       [(<= ?d ?today)]]
    :inputs           [:30d :today]
    :result-transform (fn [result]
                        (sort-by (fn [h]
                                   (get h :block/priority "Z")) result))
    :collapsed?       false}

   {:title      "📅 NEXT 5d"
    :query      [:find (pull ?h [*])
                 :in $ ?start ?next
                 :where
                 [?h :block/marker ?marker]
                 [(contains? #{"NOW" "LATER" "TODO"} ?marker)]
                 [?h :block/ref-pages ?p]
                 [?p :block/journal? true]
                 [?p :block/journal-day ?d]
                 [(> ?d ?start)]
                 [(< ?d ?next)]]
    :inputs     [:today :7d-after]
    :result-transform (fn [result]
                        (sort-by (fn [h]
                                   (get h :block/priority "Z")) result))
    :collapsed? false}

   {:title "⏰ NOW & LATER"
    :query [:find (pull ?h [*])
            :in $ ?start ?next
            :where
            [?h :block/marker ?marker]
            [(contains? #{"NOW" "LATER" "DOING"} ?marker)]
            [?h :block/page ?p]
            [?p :block/journal? true]
            [?p :block/journal-day ?d]
            [(> ?d ?start)]
            [(< ?d ?next)]]
    :inputs [:30d :today]
    :result-transform (fn [result]
                        (sort-by (fn [h]
                                   (get h :block/priority "Z")) result))
    :collapsed? true}
   
    {:title "⌚️ Waiting-For"
      :query [:find (pull ?b [*])
 		:where [?b :block/path-refs [:block/name "waiting-for"]]]
                :result-transform (fn [result]
                (sort-by (fn [h]
                (get h :block/priority "Z")) result))    
      :collapsed? true}

    ]
} ;;end query section
2 Likes

Following your exampl, but I run into a problem with the following segment:

{:title "⌚️ Waiting-For"
    :query [:find (pull ?b [*])
 		    :where [?b :block/path-refs [:block/name "waiting-for"]]]
    :result-transform (fn [result]
                        (sort-by (fn [h]
                                   (get h :block/priority "Z")) result))
    :collapsed? true}

Logseq only tells me that this query has error, but I don’t know how to find out the cause of the error.

I’m not getting an error on that part. Does it work if you take that out of the query section?

If I remove that offending part in the section of query section, then there is no complaint of error. The query for the TODO works with slight editing, as I sometimes use 'TODO" and “DOING”.

Can you copy this to a new page and see if it still errors out:

#+BEGIN_QUERY
{:title "⌚️ Waiting-For"
    :query [:find (pull ?b [*])
 		    :where [?b :block/path-refs [:block/name "waiting-for"]]]
    :result-transform (fn [result]
                        (sort-by (fn [h]
                                   (get h :block/priority "Z")) result))
    :collapsed? true}
#+END_QUERY

Yes, same error as Yu_Shen and this query errors out in a new page.

Just unpack the query then it works:

#+BEGIN_QUERY
{:title "⌚️ Waiting-For"
    :query [:find (pull ?b [*])
 		    :where 
                [?b :block/path-refs ?ref]
                [?ref :block/name "waiting-for"]
                ]
    :result-transform (fn [result]
                        (sort-by (fn [h]
                                   (get h :block/priority "Z")) result))
    :collapsed? true}
#+END_QUERY