Plugin to automatically generate reminders for events, deadlines etc

It would be great if there was a plug in to automatically generate reminders. E.g. for “Event-X [[date-Y]]” it would generate further indented bullet points as follows:

  • This week: Event-X [[date-for-Monday-of-the-relevant-week]]
  • Tomorrow: Event-X [[date-for-day-before-the-relevant-date]]
  • One week’s time: Event-X [[date-exactly-seven-days-before-the-relevant-date]]

These reminders will then appear at the bottom of daily notes via backlinks.

There could be a control panel, or options in the .edn file to specify exactly when you would like your default reminders to come in.

I think this is a good way to keep on top of scheduled events because it gives reminders at certain timepoints, but in such a way that it does not produce a long list of future events, which can be quite overwhelming, anxiety-inducing and difficult to process.

I am imagining that this would work separately from the org-mode style syntax for scheduled events, though I guess the two could be integrated?

I am planning, at some stage, to write an Alfred script which does something like this (Alfred is a brilliant automation app on Mac, if you don’t know), but I don’t really have the know how to create a Logseq addon which does this.

You can do this with queries (both simple and advanced) already.

I’m not sure how. Queries can find events / todos occurring between two dates. But what I’m imagining is a bit more complex than that. Can one create a query which only shows events today, and tomorrow, and in seven days’ time? And can you create one which shows this week’s events on a Monday only?

Last 7 days:

{{query (and (todo now todo doing later) (between -7d now))}}

Today:

{{query (and (todo now todo doing later) (between now now))}}

Yesterday:

{{query (and (todo now todo doing later) (between yesterday yesterday))}}

Maybe there’s more efficient ways, not sure. As for specific dates not sure of a way with simple queries, I’m sure there are with advanced ones but I’m not a big fan of that syntax right now.

All of this was derived and tested from https://logseq.github.io/#/page/queries

3 Likes

According to the changelog on Feb 26, 2021 I believe it was, that I just saw, queries also support dynamic variables so something like {{query (and (todo now todo doing later) (between <% this Monday %> <% this Monday %>))}} may work (untested).

https://logseq.github.io/#/page/60c8c15b-b66e-4ad8-a480-926363a34c48

I have an Agenda page which basically summarizes my to-dos:

- query-table:: false
  #+BEGIN_QUERY
    {:title [:h4 "Overdue"]
      :query [:find (pull ?block [*])
              :in $ ?start ?next
              :where
              [?block :block/marker ?marker]
              [(contains? #{"TODO","DOING"} ?marker)]
              (or
                [?block :block/scheduled ?d]
                [?block :block/deadline ?d])
              [(> ?d ?start)]
              [(< ?d ?next)]]
              :result-transform (fn [result]
                        (sort-by (fn [h]
                                   (or (get h :block/scheduled) (get h :block/deadline))) result))
      :inputs [:365d-before :0d-before]
      :collapsed? false}
    #+END_QUERY
- query-table:: false
  #+BEGIN_QUERY
    {:title [:h4 "Today"]
      :query [:find (pull ?block [*])
              :in $ ?start ?next
              :where
              (or
                [?block :block/scheduled ?d]
                [?block :block/deadline ?d])
              [(> ?d ?start)]
              [(< ?d ?next)]]
              :result-transform (fn [result]
                        (sort-by (fn [h]
                                   (or (get h :block/scheduled) (get h :block/deadline))) result))
      :inputs [:1d-before :1d-after]
      :collapsed? false}
    #+END_QUERY
- #+BEGIN_QUERY
  {:title [:h4 "Electives"]
   :query [:find (pull ?b [*])
          :where
  (or [?b :block/priority "A"] [?b :block/priority "B"] [?b :block/priority "C"])
          [?b :block/marker ?marker]
          (not [?b :block/scheduled ?d])
          (not [?b :block/deadline ?d])
          [(contains? #{"TODO","DOING"} ?marker)]]
  :result-transform 
      (fn [result]
         (sort-by (fn [h] (get h :block/priority "Z")) result))
  }
  #+END_QUERY
- query-table:: false
  #+BEGIN_QUERY
    {:title [:h4 "Sooner"]
      :query [:find (pull ?block [*])
              :in $ ?start ?next
              :where
              (or
                [?block :block/scheduled ?d]
                [?block :block/deadline ?d])
              [(> ?d ?start)]
              [(< ?d ?next)]]
              :result-transform (fn [result]
                        (sort-by (fn [h]
                                   (or (get h :block/scheduled) (get h :block/deadline))) result))
      :inputs [:0d-after :7d-after]
      :collapsed? false}
    #+END_QUERY
- #+BEGIN_QUERY
    {:title [:h4 "Later"]
      :query [:find (pull ?block [*])
              :in $ ?start ?next
              :where
              (or
                [?block :block/scheduled ?d]
                [?block :block/deadline ?d])
              [(> ?d ?start)]
              [(< ?d ?next)]]
              :result-transform (fn [result]
                        (sort-by (fn [h]
                                   (or (get h :block/scheduled) (get h :block/deadline))) result))
      :inputs [:6d-after :90d-after]
      :collapsed? false}
    #+END_QUERY
3 Likes

Dropped Electives, added Watch. The family usually watches shows together in the evening to unwind. Found it better if I could see Tomorrow as a single unit, esp. as at the end of a day I push everything which I didn’t get to, to the next day.

 :default-queries
 {:journals
  [
    {:title [:h4 "⌛ Overdue"]
      :query [:find (pull ?block [*])
              :in $ ?start ?next
              :where
              [?block :block/marker ?marker]
              [(contains? #{"TODO","DOING"} ?marker)]
              (or
                [?block :block/scheduled ?d]
                [?block :block/deadline ?d])
              [(> ?d ?start)]
              [(< ?d ?next)]]
              :result-transform (fn [result]
                        (sort-by (fn [h]
                                   (or (get h :block/scheduled) (get h :block/deadline))) result))
      :inputs [:365d-before :0d-before]
      :collapsed? false},
    {:title [:h4 "⏰ Today"]
      :query [:find (pull ?block [*])
              :in $ ?day
              :where
              (or
                [?block :block/scheduled ?d]
                [?block :block/deadline ?d])
              [(= ?d ?day)]]
      :result-transform
        (fn [result]
          (sort-by (fn [h] [(get h :block/priority "Z") (get h :block/created-at)]) result))
      :inputs [:today]
      :collapsed? false},
    {:title [:h4 "🍿 Watch"]
      :query [:find (pull ?b [*])
            :where
            (or [?b :block/priority "A"] [?b :block/priority "B"] [?b :block/priority "C"])
            [?b :block/marker ?marker]
            [?b :block/ref-pages ?p]
            (or [?p :block/name "movie"] [?p :block/name "show"])
            (not [?b :block/scheduled ?d])
            (not [?b :block/deadline ?d])
            [(contains? #{"TODO","DOING"} ?marker)]]
    :result-transform
        (fn [result]
          (sort-by (fn [h] [(get h :block/priority "Z") (get h :block/created-at)]) result))
    :collapsed? true},
    {:title [:h4 "☀️ Tomorrow"]
      :query [:find (pull ?block [*])
              :in $ ?day
              :where
              (or
                [?block :block/scheduled ?d]
                [?block :block/deadline ?d])
              [(= ?d ?day)]]
      :result-transform
        (fn [result]
          (sort-by (fn [h] [(get h :block/priority "Z") (get h :block/created-at)]) result))
      :inputs [:1d-after]
      :collapsed? false},
    {:title [:h4 "📆 Sooner"]
      :query [:find (pull ?block [*])
              :in $ ?start ?next
              :where
              (or
                [?block :block/scheduled ?d]
                [?block :block/deadline ?d])
              [(> ?d ?start)]
              [(< ?d ?next)]]
      :result-transform (fn [result]
                (sort-by (fn [h]
                            (or (get h :block/scheduled) (get h :block/deadline))) result))
      :inputs [:1d-after :7d-after]
      :collapsed? false},
    {:title [:h4 "📅 Later"]
      :query [:find (pull ?block [*])
              :in $ ?start ?next
              :where
              (or
                [?block :block/scheduled ?d]
                [?block :block/deadline ?d])
              [(> ?d ?start)]
              [(< ?d ?next)]]
      :result-transform (fn [result]
                (sort-by (fn [h]
                            (or (get h :block/scheduled) (get h :block/deadline))) result))
      :inputs [:6d-after :90d-after]
      :collapsed? true}
]}

4 Likes

mlanza, could you help me, is it possible to write a query like yours “Sooner” but asking also for tasks with only “a” priority ?

I am not well versed in datalog. Perhaps something like this:

#+BEGIN_QUERY
{:title "Sooner"
 :query [:find (pull ?block [*])
              :in $ ?start ?next
              :where
              (or
                [?block :block/scheduled ?d]
                [?block :block/deadline ?d])
              [?block :block/priority "A"]
              [(> ?d ?start)]
              [(< ?d ?next)]]
 :inputs [:1d-after :7d-after]
 :collapsed? true}
#+END_QUERY
1 Like