Skip to content

Commit

Permalink
fix: remove unnecessary block/refs task calculations
Browse files Browse the repository at this point in the history
Part of LOG-3198. Also fix test assertion and add another
  • Loading branch information
logseq-cldwalker committed Dec 4, 2024
1 parent c6bf04c commit af044dd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
9 changes: 0 additions & 9 deletions deps/graph-parser/src/logseq/graph_parser/exporter.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,6 @@
(assoc :logseq.task/status status-ident)
(update :block/title string/replace-first (re-pattern (str marker "\\s*")) "")
(update :block/tags (fnil conj []) :logseq.class/Task)
;; FIXME: block/refs property calculation should be handled by a listener
(update :block/refs (fn [refs]
(into (remove #(= marker (:block/title %)) refs)
[:logseq.class/Task :logseq.task/status])))
(dissoc :block/marker)))
block))

Expand All @@ -279,10 +275,6 @@
(-> block
(assoc :logseq.task/priority priority-value)
(update :block/title string/replace-first (re-pattern (str "\\[#" priority "\\]" "\\s*")) "")
;; FIXME: block/refs property calculation should be handled by a listener
(update :block/refs (fn [refs]
(into (remove #(= priority (:block/title %)) refs)
[:logseq.task/priority])))
(dissoc :block/priority)))
block))

Expand All @@ -309,7 +301,6 @@
{:block
(-> block
(assoc :logseq.task/deadline [:block/uuid (:block/uuid deadline-page)])
(update :block/refs (fnil into []) [:logseq.task/deadline [:block/uuid (:block/uuid deadline-page)]])
(dissoc :block/deadline :block/scheduled :block/repeated?))
:properties-tx (when-not existing-journal-page [deadline-page])})
{:block block :properties-tx []}))
Expand Down
14 changes: 9 additions & 5 deletions deps/graph-parser/test/logseq/graph_parser/exporter_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -451,28 +451,32 @@
(is (= "multiline block\na 2nd\nand a 3rd" (:block/title (find-block-by-content @conn #"multiline block"))))
(is (= "logbook block" (:block/title (find-block-by-content @conn #"logbook block")))))

(testing "block refs and path-refs"
(testing ":block/refs and :block/path-refs"
(let [page (find-page-by-name @conn "chat-gpt")]
(is (set/subset?
#{"type" "LargeLanguageModel"}
(->> page :block/refs (map #(:block/title (d/entity @conn (:db/id %)))) set))
"Correct :block/refs for property and its values on a page"))
"Page has correct property and property value :block/refs")
(is (set/subset?
#{"type" "LargeLanguageModel"}
(->> page :block/path-refs (map #(:block/title (d/entity @conn (:db/id %)))) set))
"Page has correct property and property value :block/path-refs"))

(let [block (find-block-by-content @conn "old todo block")]
(is (set/subset?
#{:logseq.task/status :logseq.class/Task}
(->> block
:block/path-refs
:block/refs
(map #(:db/ident (d/entity @conn (:db/id %))))
set))
"Correct :block/refs for block")
"Block has correct task tag and property :block/refs")
(is (set/subset?
#{:logseq.task/status :logseq.class/Task}
(->> block
:block/path-refs
(map #(:db/ident (d/entity @conn (:db/id %))))
set))
"Correct :block/path-refs for block")))
"Block has correct task tag and property :block/path-refs")))

(testing "whiteboards"
(let [block-with-props (find-block-by-content @conn #"block with props")]
Expand Down

0 comments on commit af044dd

Please sign in to comment.