فهرست منبع

fix: duplicate journal pages when deadline is on same day

as block's page. Switched to using page-names-to-uuids instead
of db since it has the uuids of current page. Fixes logseq/db-test#192
Gabriel Horner 10 ماه پیش
والد
کامیت
409107f385

+ 6 - 6
deps/graph-parser/src/logseq/graph_parser/exporter.cljs

@@ -281,12 +281,12 @@
 (defn- update-block-deadline
   ":block/title doesn't contain DEADLINE.* text so unable to detect timestamp
   or repeater usage and notify user that they aren't supported"
-  [block db {:keys [user-config]}]
+  [block page-names-to-uuids {:keys [user-config]}]
   (if-let [date-int (or (:block/deadline block) (:block/scheduled block))]
-    (let [existing-journal-page (ffirst (d/q '[:find (pull ?b [:block/uuid])
-                                               :in $ ?journal-day
-                                               :where [?b :block/journal-day ?journal-day]]
-                                             db date-int))
+    (let [existing-journal-page (some->> (date-time-util/int->journal-title date-int (common-config/get-date-formatter user-config))
+                                         common-util/page-name-sanity-lc
+                                         (get @page-names-to-uuids)
+                                         (hash-map :block/uuid))
           deadline-page (->
                          (or existing-journal-page
                             ;; FIXME: Register new pages so that two different refs to same new page
@@ -842,7 +842,7 @@
   (let [;; needs to come before update-block-refs to detect new property schemas
         {:keys [block properties-tx]}
         (handle-block-properties block* db page-names-to-uuids (:block/refs block*) options)
-        {block-after-built-in-props :block deadline-properties-tx :properties-tx} (update-block-deadline block db options)
+        {block-after-built-in-props :block deadline-properties-tx :properties-tx} (update-block-deadline block page-names-to-uuids options)
         ;; :block/page should be [:block/page NAME]
         journal-page-created-at (some-> (:block/page block*) second journal-created-ats)
         prepared-block (cond-> block-after-built-in-props

+ 6 - 0
deps/graph-parser/test/logseq/graph_parser/exporter_test.cljs

@@ -304,6 +304,12 @@
              (readable-properties @conn (find-block-by-content @conn "only scheduled")))
           "scheduled block converted to correct deadline")
 
+      (is (= 1 (count (d/q '[:find [(pull ?b [*]) ...]
+                             :in $ ?content
+                             :where [?b :block/title ?content]]
+                           @conn "Apr 1st, 2024")))
+          "Only one journal page exists when deadline is on same day as journal")
+
       (is (= {:logseq.task/priority "High"}
              (readable-properties @conn (find-block-by-content @conn "high priority")))
           "priority block has correct property")

+ 3 - 1
deps/graph-parser/test/resources/exporter-test-graph/journals/2024_04_01.md

@@ -7,4 +7,6 @@
 - DOING [#B] status test
   :LOGBOOK:
   CLOCK: [2024-04-01 Mon 10:39:40]
-  :END:
+  :END:
+- deadline on same day
+  DEADLINE: <2024-04-01 Mon 13:50>