ahonn / logseq-plugin-todo

A simple to-do list plugin for logseq
MIT License
157 stars 11 forks source link

dedicated query for displaying schedule todo on journal #58

Closed pekcheey closed 1 year ago

pekcheey commented 1 year ago

As of v1.19.0, on the latest journal page no later than today, there is a query titled SCHEDULED AND DEADLINE which list tasks scheduled for today and future.

In the interest of reducing clutter, it might be good to have a query that displays tasks scheduled for the current journal day only.

To that end, I've a query that list the tasks scheduled for that journal date. it might be useful to provide a similar query as a template within the plugin that users can include on their journal pages.

#+BEGIN_QUERY
{
:inputs [:current-page]
 :title [:h3 "✅ Planned"]
 :query [:find (pull ?b [*])
         :in $ ?process_dt ; YYYY-MM-DD
 :where
   [?b :block/marker ?marker]
   [(contains? #{"TODO" "LATER"} ?marker)]  ; TODO put in a value list with LATER.
   [?b :block/scheduled ?sd]  ; ?b has attribute scheduled with value ?sd, ?sd is not further specified and so is any value. The same can be accomplish with _
   [(str ?sd) ?sds]               ; get scheduled date str
  ;; remove hyphen
   [(subs  ?process_dt 0 4 ) ?yyyy]             ; YEAR
   [(subs  ?process_dt 5 7 ) ?mm]               ; MONTH
   [(subs  ?process_dt 8   ) ?dd]               ; DAY
   [(str   ?yyyy ?mm ?dd  ) ?process_dt_str]    ; combine to date string
   [(= ?process_dt_str ?sds)]              ; processing date str should equal scheduled date 
 ]
   :result-transform (fn [result] (sort-by (fn [r] (get-in r [:block/scheduled])) result)) ; sort the result by the scheduled date
;; :view (fn [r] [:pre.code (pprint r)])
;; :view (fn [r] [:pre.code(pprint "2023")])
;; :view (fn [r] [:pre.code(pprint :current-page)])
 :table-view? false
 :breadcrumb-show? false  ; don't show the parent blocks in the result !important, due to result-transform the grouping is lost, and so you will be left with a simple list of TODO items. having those parents blocks mixed in may make the list more confusing. (setting this to true won't show the page btw!)
 :collapsed? false
}
#+END_QUERY

As it stands, the query is specific to my journal format YYYY-MM-DD I'm basically new to clojure and does not know how to pull the date associated with the journal page. So I can only make do with forming the date with string manipulation

the query would be especially useful in a future dated journal entry that have todos scheduled.

ahonn commented 1 year ago

SCHEDULED AND DEADLINE is not a feature provided by this plugin, but by Logseq itself. You can disable it in config.edn by setting :feature/disable-scheduled-and-deadline-query? true.

See https://github.com/logseq/logseq/blob/183e153eadbdc7cb156482006092a53de6cbde3c/src/resources/templates/config.edn#L78

pekcheey commented 1 year ago

I see. thought the todo plugin does, IMO, makes it easier to use task scheduling. are you suggesting perhaps that this issue should be open on the main logseq issue tracker?

That makes sense to me. Thanks for the direction!