fix: scheduled and deadlines no long works

pull/8843/merge
Tienson Qin 2023-04-04 00:43:58 +08:00
parent 0352a14486
commit f7f2a26fa6
3 changed files with 24 additions and 16 deletions

View File

@ -21,14 +21,15 @@
(let [scheduled-or-deadlines (when (scheduled-or-deadlines? page-name)
(db/get-date-scheduled-or-deadlines (string/capitalize page-name)))]
(when (seq scheduled-or-deadlines)
(ui/foldable
[:h2.font-medium "SCHEDULED AND DEADLINE"]
[:div.scheduled-deadlines.references-blocks.mb-6
(let [ref-hiccup (block/->hiccup scheduled-or-deadlines
{:id (str page-name "-agenda")
:ref? true
:group-by-page? true
:editor-box editor/box}
{})]
(content/content page-name {:hiccup ref-hiccup}))]
{:title-trigger? true}))))
[:div.scheduled-or-deadlines.mt-8
(ui/foldable
[:h2.font-medium "SCHEDULED AND DEADLINE"]
[:div.scheduled-deadlines.references-blocks.mb-6
(let [ref-hiccup (block/->hiccup scheduled-or-deadlines
{:id (str page-name "-agenda")
:ref? true
:group-by-page? true
:editor-box editor/box}
{})]
(content/content page-name {:hiccup ref-hiccup}))]
{:title-trigger? true})])))

View File

@ -21,7 +21,9 @@
[logseq.graph-parser.text :as text]
[logseq.graph-parser.util.page-ref :as page-ref]
[logseq.graph-parser.util.db :as db-util]
[logseq.graph-parser.util :as gp-util]))
[logseq.graph-parser.util :as gp-util]
[cljs-time.core :as t]
[cljs-time.format :as tf]))
;; lazy loading
@ -1268,9 +1270,14 @@ independent of format as format specific heading characters are stripped"
(defn get-date-scheduled-or-deadlines
[journal-title]
(when-let [date (date/journal-title->int journal-title)]
(let [future-days (state/get-scheduled-future-days)]
(let [future-days (state/get-scheduled-future-days)
date-format "yyyyMMdd"
current-day (tf/parse (tf/formatter date-format) (str date))
future-day (->> (t/plus current-day (t/days future-days))
(tf/unparse date-format))]
(when-let [repo (state/get-current-repo)]
(->> (react/q repo [:custom :scheduled-deadline journal-title] {}
(->> (react/q repo [:custom :scheduled-deadline journal-title]
{:use-cache? false}
'[:find [(pull ?block ?block-attrs) ...]
:in $ ?day ?future ?block-attrs
:where
@ -1287,7 +1294,7 @@ independent of format as format specific heading characters are stripped"
[(true? ?repeated)]
[(>= ?d ?day)])]
date
(+ date future-days)
future-day
block-attrs)
react
(sort-by-left-recursive)

View File

@ -496,7 +496,7 @@ should be done through this fn in order to get global config and config defaults
(defn get-scheduled-future-days
[]
(let [days (:scheduled/future-days (get-config))]
(or (when (int? days) days) 0)))
(or (when (int? days) days) 14)))
(defn get-start-of-week
[]