Skip to content

Commit

Permalink
fix: deadline query doesn't work for db graphs
Browse files Browse the repository at this point in the history
Fixes LOG-3245
  • Loading branch information
logseq-cldwalker committed Dec 7, 2024
1 parent b89a492 commit f5666fa
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 25 deletions.
64 changes: 40 additions & 24 deletions src/main/frontend/db/async.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -232,30 +232,46 @@
future-day (some->> (t/plus current-day (t/days future-days))
(tf/unparse date-format)
(parse-long))]
(when future-day
(when-let [repo (state/get-current-repo)]
(p/let [result (<q repo {}
'[:find [(pull ?block ?block-attrs) ...]
:in $ ?day ?future ?block-attrs
:where
(or
[?block :block/scheduled ?d]
[?block :block/deadline ?d])
[(get-else $ ?block :block/repeated? false) ?repeated]
[(get-else $ ?block :block/marker "NIL") ?marker]
[(not= ?marker "DONE")]
[(not= ?marker "CANCELED")]
[(not= ?marker "CANCELLED")]
[(<= ?d ?future)]
(or-join [?repeated ?d ?day]
[(true? ?repeated)]
[(>= ?d ?day)])]
date
future-day
db-model/file-graph-block-attrs)]
(->> result
db-model/sort-by-order-recursive
db-utils/group-by-page)))))))
(when-let [repo (and future-day (state/get-current-repo))]
(p/let [result
(if (config/db-based-graph? repo)
(<q repo {}
'[:find [(pull ?block ?block-attrs) ...]
:in $ ?day ?future ?block-attrs
:where
[?block :logseq.task/deadline ?deadline]
[?deadline :block/journal-day ?d]
[?block :logseq.task/status ?status]
[?status :db/ident ?status-ident]
[(not= ?status-ident :logseq.task/status.done)]
[(not= ?status-ident :logseq.task/status.canceled)]
[(<= ?d ?future)]
[(>= ?d ?day)]]
date
future-day
'[*])
(<q repo {}
'[:find [(pull ?block ?block-attrs) ...]
:in $ ?day ?future ?block-attrs
:where
(or
[?block :block/scheduled ?d]
[?block :block/deadline ?d])
[(get-else $ ?block :block/repeated? false) ?repeated]
[(get-else $ ?block :block/marker "NIL") ?marker]
[(not= ?marker "DONE")]
[(not= ?marker "CANCELED")]
[(not= ?marker "CANCELLED")]
[(<= ?d ?future)]
(or-join [?repeated ?d ?day]
[(true? ?repeated)]
[(>= ?d ?day)])]
date
future-day
db-model/file-graph-block-attrs))]
(->> result
db-model/sort-by-order-recursive
db-utils/group-by-page))))))

(defn <get-tag-pages
[graph tag-id]
Expand Down
2 changes: 1 addition & 1 deletion src/main/frontend/db/query_dsl.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ Some bindings in this fn:
(pre-transform q')))

(def db-block-attrs
"Like ldb/block-attrs but for query dsl an db graphs"
"Block attributes for db graph queries"
;; '*' needed as we need to pull user properties and don't know their names in advance
'[*
{:block/page [:db/id :block/name :block/title :block/journal-day]}
Expand Down

0 comments on commit f5666fa

Please sign in to comment.