fix: remove gp-db ns, especially since it's unused

or incorrect in case of graph-view. Removed file graph
specific tests that depended on gp-db
This commit is contained in:
Gabriel Horner
2025-12-30 16:26:57 -05:00
parent 273eef800b
commit 2bcc331916
10 changed files with 17 additions and 647 deletions

View File

@@ -199,7 +199,6 @@
logseq.db.test.helper db-test
logseq.graph-parser graph-parser
logseq.graph-parser.block gp-block
logseq.graph-parser.db gp-db
logseq.graph-parser.mldoc gp-mldoc
logseq.graph-parser.property gp-property
logseq.graph-parser.text text

View File

@@ -1,7 +1,6 @@
(ns logseq.db
"Main namespace for db fns that handles DB and file graphs. For db graph only
fns, use logseq.db.frontend.db and for file graph only fns, use
logseq.graph-parser.db"
fns, you can also use logseq.db.frontend.db."
(:require [clojure.set :as set]
[clojure.string :as string]
[clojure.walk :as walk]

View File

@@ -1,7 +1,6 @@
{:paths ["src"]
:api-namespaces [logseq.graph-parser.property
logseq.graph-parser.exporter
logseq.graph-parser.db
;; Used in tests
logseq.graph-parser.test.docs-graph-helper
logseq.graph-parser.schema.mldoc]

View File

@@ -1,68 +0,0 @@
(ns logseq.graph-parser.db
"File graph specific db fns"
(:require [clojure.set :as set]
[clojure.string :as string]
[datascript.core :as d]
[logseq.common.util :as common-util]
[logseq.common.uuid :as common-uuid]
[logseq.db :as ldb]
[logseq.db.file-based.schema :as file-schema]))
(defonce built-in-markers
["NOW" "LATER" "DOING" "DONE" "CANCELED" "CANCELLED" "IN-PROGRESS" "TODO" "WAIT" "WAITING"])
(defonce built-in-priorities
["A" "B" "C"])
(defonce built-in-pages-names
(set/union
(set built-in-markers)
(set built-in-priorities)
#{"Favorites" "Contents" "card"}))
(defn- page-title->block
[title]
{:block/name (string/lower-case title)
:block/title title
:block/uuid (common-uuid/gen-uuid)
:block/type "page"})
(def built-in-pages
(mapv page-title->block built-in-pages-names))
(defn- build-pages-tx
[pages]
(let [time' (common-util/time-ms)]
(map
(fn [m]
(-> m
(assoc :block/created-at time')
(assoc :block/updated-at time')))
pages)))
(defn create-default-pages!
"Creates default pages if one of the default pages does not exist. This
fn is idempotent"
[db-conn]
(when-not (ldb/get-page @db-conn "card")
(let [built-in-pages' (build-pages-tx built-in-pages)]
(ldb/transact! db-conn built-in-pages'))))
(defn start-conn
"Create datascript conn with schema and default data"
[]
(let [db-conn (d/create-conn file-schema/schema)]
(create-default-pages! db-conn)
db-conn))
(defn get-page-file
[db page-name]
(some-> (ldb/get-page db page-name)
:block/file))
(defn get-all-namespace-relation
[db]
(d/q '[:find ?page ?parent
:where
[?page :block/namespace ?parent]]
db))

View File

@@ -1,9 +1,6 @@
(ns logseq.graph-parser.block-test
(:require [logseq.graph-parser.block :as gp-block]
[logseq.graph-parser.mldoc :as gp-mldoc]
[logseq.graph-parser :as graph-parser]
[logseq.graph-parser.db :as gp-db]
[logseq.common.util.block-ref :as block-ref]
[datascript.core :as d]
[cljs.test :refer [deftest are testing is]]))
@@ -118,50 +115,4 @@
db
content)
(map first)
first))
(defn- parse-file
[conn file-path file-content & [options]]
(graph-parser/parse-file conn file-path file-content (merge-with merge options {:extract-options {:verbose false}})))
(deftest refs-from-block-refs
(let [conn (gp-db/start-conn)
id "63f528da-284a-45d1-ac9c-5d6a7435f6b4"
block (str "A block\nid:: " id)
block-ref-via-content (str "Link to " (block-ref/->block-ref id))
block-ref-via-block-properties (str "B block\nref:: " (block-ref/->block-ref id))
body (str "- " block "\n- " block-ref-via-content "\n- " block-ref-via-block-properties)]
(parse-file conn "foo.md" body {})
(testing "Block refs in blocks"
(is (= [{:block/uuid (uuid id)}]
(:block/refs (find-block-for-content @conn block-ref-via-content)))
"Block that links to a block via paragraph content has correct block ref")
(is (contains?
(set (:block/refs (find-block-for-content @conn block-ref-via-block-properties)))
{:block/uuid (uuid id)})
"Block that links to a block via block properties has correct block ref"))
(testing "Block refs in pre-block"
(let [block-ref-via-page-properties (str "page-ref:: " (block-ref/->block-ref id))]
(parse-file conn "foo2.md" block-ref-via-page-properties {})
(is (contains?
(set (:block/refs (find-block-for-content @conn block-ref-via-page-properties)))
{:block/uuid (uuid id)})
"Block that links to a block via page properties has correct block ref")))))
(deftest timestamp-blocks
(let [conn (gp-db/start-conn)
deadline-block "do something\nDEADLINE: <2023-02-21 Tue>"
scheduled-block "do something else\nSCHEDULED: <2023-02-20 Mon>"
body (str "- " deadline-block "\n- " scheduled-block)]
(parse-file conn "foo.md" body {})
(is (= 20230220
(:block/scheduled (find-block-for-content @conn scheduled-block)))
"Scheduled block has correct block attribute and value")
(is (= 20230221
(:block/deadline (find-block-for-content @conn deadline-block)))
"Deadline block has correct block attribute and value")))
first))

View File

@@ -1,448 +0,0 @@
(ns logseq.graph-parser-test
(:require [cljs.test :refer [deftest testing is are]]
[clojure.string :as string]
[datascript.core :as d]
[logseq.db :as ldb]
[logseq.graph-parser :as graph-parser]
[logseq.graph-parser.block :as gp-block]
[logseq.graph-parser.db :as gp-db]
[logseq.graph-parser.property :as gp-property]))
(def foo-edn
"Example exported whiteboard page as an edn exportable."
'{:blocks
({:block/title "foo content a",
:block/format :markdown
:block/parent {:block/uuid #uuid "16c90195-6a03-4b3f-839d-095a496d9acd"}},
{:block/title "foo content b",
:block/format :markdown
:block/parent {:block/uuid #uuid "16c90195-6a03-4b3f-839d-095a496d9acd"}}),
:pages
({:block/format :markdown,
:block/name "foo"
:block/title "Foo"
:block/uuid #uuid "16c90195-6a03-4b3f-839d-095a496d9acd"
:block/properties {:title "my whiteboard foo"}})})
(def foo-conflict-edn
"Example exported whiteboard page as an edn exportable."
'{:blocks
({:block/title "foo content a",
:block/format :markdown},
{:block/title "foo content b",
:block/format :markdown}),
:pages
({:block/format :markdown,
:block/name "foo conflicted"
:block/title "Foo conflicted"
:block/uuid #uuid "16c90195-6a03-4b3f-839d-095a496d9acd"})})
(def bar-edn
"Example exported whiteboard page as an edn exportable."
'{:blocks
({:block/title "foo content a",
:block/format :markdown
:block/parent {:block/uuid #uuid "71515b7d-b5fc-496b-b6bf-c58004a34ee3"
:block/name "foo"}},
{:block/title "foo content b",
:block/format :markdown
:block/parent {:block/uuid #uuid "71515b7d-b5fc-496b-b6bf-c58004a34ee3"
:block/name "foo"}}),
:pages
({:block/format :markdown,
:block/name "bar"
:block/title "Bar"
:block/uuid #uuid "71515b7d-b5fc-496b-b6bf-c58004a34ee3"})})
(defn- parse-file
[conn file-path file-content & [options]]
(graph-parser/parse-file conn file-path file-content (merge-with merge options {:extract-options {:verbose false}})))
(deftest parse-file-test
(testing "id properties"
(let [conn (gp-db/start-conn)]
(parse-file conn "foo.md" "- id:: 628953c1-8d75-49fe-a648-f4c612109098")
(is (= [{:id "628953c1-8d75-49fe-a648-f4c612109098"}]
(->> (d/q '[:find (pull ?b [*])
:in $
:where [?b :block/title] [(missing? $ ?b :block/name)]]
@conn)
(map first)
(map :block/properties)))
"id as text has correct :block/properties")))
(testing "unexpected failure during block extraction"
(let [conn (gp-db/start-conn)
deleted-page (atom nil)]
(with-redefs [gp-block/with-pre-block-if-exists (fn stub-failure [& _args]
(throw (js/Error "Testing unexpected failure")))]
(try
(parse-file conn "foo.md" "- id:: 628953c1-8d75-49fe-a648-f4c612109098"
{:delete-blocks-fn (fn [page _file _uuids]
(reset! deleted-page page))})
(catch :default _)))
(is (= nil @deleted-page)
"Page should not be deleted when there is unexpected failure")))
(testing "parsing whiteboard page"
(let [conn (gp-db/start-conn)]
(parse-file conn "/whiteboards/foo.edn" (pr-str foo-edn))
(let [blocks (d/q '[:find (pull ?b [* {:block/page
[:block/name
:block/title
:block/type
{:block/file
[:file/path]}]}])
:in $
:where [?b :block/title] [(missing? $ ?b :block/name)]]
@conn)
parent (:block/page (ffirst blocks))]
(is (= {:block/name "foo"
:block/title "Foo"
:block/type "whiteboard"
:block/file {:file/path "/whiteboards/foo.edn"}}
parent)
"parsed block in the whiteboard page has correct parent page"))))
(testing "Loading whiteboard pages that same block/uuid should throw an error."
(let [conn (gp-db/start-conn)]
(parse-file conn "/whiteboards/foo.edn" (pr-str foo-edn))
;; Reduce output with with-out-str
(with-out-str
(is (thrown-with-msg?
js/Error
#"Conflicting upserts"
(parse-file conn "/whiteboards/foo-conflict.edn" (pr-str foo-conflict-edn)))))))
(testing "Loading whiteboard pages should ignore the :block/name property inside :block/parent."
(let [conn (gp-db/start-conn)]
(parse-file conn "/whiteboards/foo.edn" (pr-str foo-edn))
(parse-file conn "/whiteboards/bar.edn" (pr-str bar-edn))
(let [pages (d/q '[:find ?name
:in $
:where
[?b :block/name ?name]
[?b :block/type "whiteboard"]]
@conn)]
(is (= pages #{["foo"] ["bar"]}))))))
(defn- test-property-order [num-properties]
(let [conn (gp-db/start-conn)
properties (mapv #(keyword (str "p" %)) (range 0 num-properties))
text (->> properties
(map #(str (name %) ":: " (name %) "-value"))
(string/join "\n"))
;; Test page properties and block properties
body (str text "\n- " text)
_ (parse-file conn "foo.md" body)
properties-orders (->> (d/q '[:find (pull ?b [*])
:in $
:where [?b :block/title] [(missing? $ ?b :block/name)]]
@conn)
(map first)
(map :block/properties-order))]
(is (every? vector? properties-orders)
"Order is persisted as a vec to avoid edn serialization quirks")
(is (= [properties properties] properties-orders)
"Property order")))
(deftest properties-order
(testing "Sort order and persistence of a few properties"
(test-property-order 4))
(testing "Sort order and persistence of 10 properties"
(test-property-order 10)))
(deftest quoted-property-values
(let [conn (gp-db/start-conn)
_ (parse-file conn
"foo.md"
"- desc:: \"#foo is not a ref\""
{:extract-options {:user-config {}}})
block (->> (d/q '[:find (pull ?b [* {:block/refs [*]}])
:in $
:where [?b :block/properties]]
@conn)
(map first)
first)]
(is (= {:desc "\"#foo is not a ref\""}
(:block/properties block))
"Quoted value is unparsed")
(is (= ["desc"]
(map :block/title (:block/refs block)))
"No refs from property value")))
(deftest non-string-property-values
(let [conn (gp-db/start-conn)]
(parse-file conn
"lythe-of-heaven.md"
"rating:: 8\nrecommend:: true\narchive:: false")
(is (= {:rating 8 :recommend true :archive false}
(->> (d/q '[:find (pull ?b [*])
:in $
:where [?b :block/properties]]
@conn)
(map (comp :block/properties first))
first)))))
(deftest linkable-built-in-properties
(let [conn (gp-db/start-conn)
_ (parse-file conn
"lol.md"
(str "alias:: 233\ntags:: fun, facts"
"\n- "
"alias:: 666\ntags:: block, facts"))
page-block (->> (d/q '[:find (pull ?b [:block/properties {:block/alias [:block/name]} {:block/tags [:block/name]}])
:in $
:where [?b :block/name "lol"]]
@conn)
(map first)
first)
block (->> (d/q '[:find (pull ?b [:block/properties])
:in $
:where
[?b :block/properties]
[(missing? $ ?b :block/pre-block?)]
[(missing? $ ?b :block/name)]]
@conn)
(map first)
first)]
(is (= {:block/alias [{:block/name "233"}]
:block/tags [{:block/name "fun"} {:block/name "facts"}]
:block/properties {:alias #{"233"} :tags #{"fun" "facts"}}}
page-block)
"page properties, alias and tags are correct")
(is (every? set? (vals (:block/properties page-block)))
"Linked built-in property values as sets provides for easier transforms")
(is (= {:block/properties {:alias #{"666"} :tags #{"block" "facts"}}}
block)
"block properties are correct")))
(defn- property-relationships-test
"Runs tests on page properties and block properties. file-properties is what is
visible in a file and db-properties is what is pulled out from the db"
[file-properties db-properties user-config]
(let [conn (gp-db/start-conn)
page-content (gp-property/->block-content file-properties)
;; Create Block properties from given page ones
block-property-transform (fn [m] (update-keys m #(keyword (str "block-" (name %)))))
block-file-properties (block-property-transform file-properties)
block-content (gp-property/->block-content block-file-properties)
_ (parse-file conn
"property-relationships.md"
(str page-content "\n- " block-content)
{:extract-options {:user-config user-config}})
pages (->> (d/q '[:find (pull ?b [* :block/properties])
:in $
:where [?b :block/name] [?b :block/properties]]
@conn)
(map first))
_ (assert (= 1 (count pages)))
blocks (->> (d/q '[:find (pull ?b [:block/pre-block?
:block/properties
:block/properties-text-values
{:block/refs [:block/title]}])
:in $
:where [?b :block/properties] [(missing? $ ?b :block/name)]]
@conn)
(map first)
(map (fn [m] (update m :block/refs #(map :block/title %)))))
block-db-properties (block-property-transform db-properties)]
(testing "Page properties"
(is (= db-properties (:block/properties (first pages)))
"page has expected properties")
(is (= file-properties (:block/properties-text-values (first pages)))
"page has expected full text of properties"))
(testing "Pre-block and block properties"
(is (= [true nil] (map :block/pre-block? blocks))
"page has 2 blocks, one of which is a pre-block")
(is (= [db-properties block-db-properties]
(map :block/properties blocks))
"pre-block/page and block have expected properties")
(is (= [file-properties block-file-properties]
(map :block/properties-text-values blocks))
"pre-block/page and block have expected full text of properties")
;; has expected refs
(are [db-props refs]
(= (->> (vals db-props)
;; ignore string values
(mapcat #(if (coll? %) % []))
(concat (map name (keys db-props)))
set)
(set refs))
; pre-block/page has expected refs
db-properties (first (map :block/refs blocks))
;; block has expected refs
block-db-properties (second (map :block/refs blocks))))))
(deftest property-relationships
(let [properties {:single-link "[[bar]]"
:multi-link "[[Logseq]] is the fastest #triples #[[text editor]]"
:desc "This is a multiple sentence description. It has one [[link]]"
:comma-prop "one, two,three"}]
(property-relationships-test
properties
{:single-link #{"bar"}
:multi-link #{"Logseq" "triples" "text editor"}
:desc #{"link"}
:comma-prop "one, two,three"}
{})))
(deftest invalid-properties
(let [conn (gp-db/start-conn)
properties {"foo" "valid"
"[[foo]]" "invalid"
"some,prop" "invalid"
"#blarg" "invalid"}
body (str (gp-property/->block-content properties)
"\n- " (gp-property/->block-content properties))]
(parse-file conn "foo.md" body)
(is (= [{:block/properties {:foo "valid"}
:block/invalid-properties #{"[[foo]]" "some,prop" "#blarg"}}]
(->> (d/q '[:find (pull ?b [*])
:in $
:where
[?b :block/properties]
[(missing? $ ?b :block/pre-block?)]
[(missing? $ ?b :block/name)]]
@conn)
(map first)
(map #(select-keys % [:block/properties :block/invalid-properties]))))
"Has correct (in)valid block properties")
(is (= [{:block/properties {:foo "valid"}
:block/invalid-properties #{"[[foo]]" "some,prop" "#blarg"}}]
(->> (d/q '[:find (pull ?b [*])
:in $
:where [?b :block/properties] [?b :block/name]]
@conn)
(map first)
(map #(select-keys % [:block/properties :block/invalid-properties]))))
"Has correct (in)valid page properties")))
(deftest correct-page-names-created-from-title
(testing "from title"
(let [conn (gp-db/start-conn)
built-in-pages (set (map string/lower-case gp-db/built-in-pages-names))]
(parse-file conn "foo.md" "title:: core.async")
(is (= #{"core.async"}
(->> (d/q '[:find (pull ?b [*])
:in $
:where [?b :block/name]]
@conn)
(map (comp :block/name first))
(remove built-in-pages)
set)))))
(testing "from cased org title"
(let [conn (gp-db/start-conn)
built-in-pages (set gp-db/built-in-pages-names)]
(parse-file conn
"foo.org"
":PROPERTIES:
:ID: 72289d9a-eb2f-427b-ad97-b605a4b8c59b
:END:
#+tItLe: Well parsed!")
(is (= #{"Well parsed!"}
(->> (d/q '[:find (pull ?b [*])
:in $
:where [?b :block/name]]
@conn)
(map (comp :block/title first))
(remove built-in-pages)
set))))))
(deftest correct-page-names-created-from-page-refs
(testing "for file, mailto, web and other uris in markdown"
(let [conn (gp-db/start-conn)
built-in-pages (set (map string/lower-case gp-db/built-in-pages-names))]
(parse-file conn
"foo.md"
(str "- [title]([[bar]])\n"
;; all of the uris below do not create pages
"- ![image.png](../assets/image_1630480711363_0.png)\n"
"- [Filename.txt](file:///E:/test/Filename.txt)\n"
"- [mail](mailto:test@test.com?subject=TestSubject)\n"
"- [onenote link](onenote:https://d.docs.live.net/b2127346582e6386a/blablabla/blablabla/blablabla%20blablabla.one#Etat%202019&section-id={133DDF16-9A1F-4815-9A05-44303784442E6F94}&page-id={3AAB677F0B-328F-41D0-AFF5-66408819C085}&end)\n"
"- [lock file](deps/graph-parser/yarn.lock)"
"- [example](https://example.com)"))
(is (= #{"foo" "bar"}
(->> (d/q '[:find (pull ?b [*])
:in $
:where [?b :block/name]]
@conn)
(map (comp :block/name first))
(remove built-in-pages)
set)))))
(testing "for web and page uris in org"
(let [conn (gp-db/start-conn)
built-in-pages (set (map string/lower-case gp-db/built-in-pages-names))]
(parse-file conn
"foo.org"
(str "* [[bar][title]]\n"
;; all of the uris below do not create pages
"* [[https://example.com][example]]\n"
"* [[../assets/conga_parrot.gif][conga]]"))
(is (= #{"foo" "bar"}
(->> (d/q '[:find (pull ?b [*])
:in $
:where [?b :block/name]]
@conn)
(map (comp :block/name first))
(remove built-in-pages)
set))))))
(deftest duplicated-ids
(testing "duplicated block ids in same file"
(let [conn (gp-db/start-conn)
extract-block-ids (atom #{})
parse-opts {:extract-options {:extract-block-ids extract-block-ids}}
block-id #uuid "63f199bc-c737-459f-983d-84acfcda14fe"]
(parse-file conn
"foo.md"
"- foo
id:: 63f199bc-c737-459f-983d-84acfcda14fe
- bar
id:: 63f199bc-c737-459f-983d-84acfcda14fe
"
parse-opts)
(let [blocks (:block/_parent (ldb/get-page @conn "foo"))]
(is (= 2 (count blocks)))
(is (= 1 (count (filter #(= (:block/uuid %) block-id) blocks)))))))
(testing "duplicated block ids in multiple files"
(let [conn (gp-db/start-conn)
extract-block-ids (atom #{})
parse-opts {:extract-options {:extract-block-ids extract-block-ids}}
block-id #uuid "63f199bc-c737-459f-983d-84acfcda14fe"]
(parse-file conn
"foo.md"
"- foo
id:: 63f199bc-c737-459f-983d-84acfcda14fe
bar
- test"
parse-opts)
(parse-file conn
"bar.md"
"- bar
id:: 63f199bc-c737-459f-983d-84acfcda14fe
bar
- test
"
parse-opts)
(is (= "foo"
(-> (d/entity @conn [:block/uuid block-id])
:block/page
:block/name)))
(let [bar-block (first (:block/_parent (ldb/get-page @conn "bar")))]
(is (some? (:block/uuid bar-block)))
(is (not= (:block/uuid bar-block) block-id))))))

View File

@@ -1,65 +0,0 @@
(ns logseq.publishing.db-test
(:require [cljs.test :refer [deftest is]]
[clojure.set :as set]
[logseq.publishing.db :as publish-db]
[logseq.graph-parser :as graph-parser]
[datascript.core :as d]
[logseq.graph-parser.db :as gp-db]
[logseq.db :as ldb]))
(deftest clean-export!
(let [conn (gp-db/start-conn)
_ (graph-parser/parse-file conn "page1.md" "public:: false\n- b11\n- b12\n- ![awesome.png](../assets/awesome_1648822509908_0.png)")
_ (graph-parser/parse-file conn "page2.md" "- b21\n- ![thumb-on-fire.PNG](../assets/thumb-on-fire_1648822523866_0.PNG)")
_ (graph-parser/parse-file conn "page3.md" "- b31")
[filtered-db assets] (publish-db/clean-export! @conn {})
exported-pages (->> (d/q '[:find (pull ?b [*])
:where [?b :block/name]]
filtered-db)
(map (comp :block/name first))
set)
exported-blocks (->> (d/q '[:find (pull ?p [*])
:where
[?b :block/title]
[?b :block/page ?p]]
filtered-db)
(map (comp :block/name first))
set)]
(is (set/subset? #{"page2" "page3"} exported-pages)
"Contains all pages that haven't been marked private")
(is (not (contains? exported-pages "page1"))
"Doesn't contain private page")
(is (= #{"page2" "page3"} exported-blocks)
"Only exports blocks from public pages")
(is (= ["thumb-on-fire_1648822523866_0.PNG"] assets)
"Only exports assets from public pages")))
(deftest filter-only-public-pages-and-blocks
(let [conn (gp-db/start-conn)
_ (graph-parser/parse-file conn "page1.md" "- b11\n- b12\n- ![awesome.png](../assets/awesome_1648822509908_0.png)")
_ (graph-parser/parse-file conn "page2.md" "alias:: page2-alias\npublic:: true\n- b21\n- ![thumb-on-fire.PNG](../assets/thumb-on-fire_1648822523866_0.PNG)")
_ (graph-parser/parse-file conn "page3.md" "public:: true\n- b31")
[filtered-db assets] (publish-db/filter-only-public-pages-and-blocks @conn {})
exported-pages (->> (d/q '[:find (pull ?b [*])
:where [?b :block/name]]
filtered-db)
(map (comp :block/name first))
set)
exported-block-pages (->> (d/q '[:find (pull ?p [*])
:where
[?b :block/title]
[?b :block/page ?p]]
filtered-db)
(map (comp :block/name first))
set)]
(is (set/subset? #{"page2" "page3"} exported-pages)
"Contains all pages that have been marked public")
(is (not (contains? exported-pages "page1"))
"Doesn't contain private page")
(is (seq (ldb/get-page filtered-db "page2-alias"))
"Alias of public page is exported")
(is (= #{"page2" "page3"} exported-block-pages)
"Only exports blocks from public pages")
(is (= ["thumb-on-fire_1648822523866_0.PNG"] assets)
"Only exports assets from public pages")))

View File

@@ -5,8 +5,7 @@
[datascript.core :as d]
[logseq.common.util :as common-util]
[logseq.db :as ldb]
[logseq.db.sqlite.create-graph :as sqlite-create-graph]
[logseq.graph-parser.db :as gp-db]))
[logseq.db.sqlite.create-graph :as sqlite-create-graph]))
(defn- build-links
[links]
@@ -79,7 +78,8 @@
(let [dark? (= "dark" theme)
relation (ldb/get-pages-relation db journal?)
tagged-pages (ldb/get-all-tagged-pages db)
namespaces (gp-db/get-all-namespace-relation db)
;; FIXME: Implement for DB graphs
namespaces []
tags (set (map second tagged-pages))
full-pages (ldb/get-all-pages db)
created-ats (map :block/created-at full-pages)
@@ -175,7 +175,8 @@
tags (set (remove #(= page-id %) tags))
ref-pages (get-page-referenced-pages db page-id)
mentioned-pages (get-pages-that-mentioned-page db page-id show-journal)
namespaces (gp-db/get-all-namespace-relation db)
;; FIXME: Implement for DB graphs
namespaces []
links (concat
namespaces
(map (fn [ref-page]
@@ -213,7 +214,8 @@
(if (ldb/page? b) b (:block/page b))))
(remove (fn [node] (= (:db/id block) (:db/id node))))
(common-util/distinct-by :db/id))
namespaces (gp-db/get-all-namespace-relation db)
;; FIXME: Implement for DB graphs
namespaces []
links (->> (concat
namespaces
(map (fn [p] [(:db/id block) (:db/id p)]) ref-blocks))

View File

@@ -11,7 +11,6 @@
[logseq.common.util :as common-util]
[logseq.db :as ldb]
[logseq.db.frontend.schema :as db-schema]
[logseq.graph-parser.db :as gp-db]
[logseq.graph-parser.text :as text]))
(defonce conns db-conn-state/conns)
@@ -81,9 +80,7 @@
(start! repo {}))
([repo {:keys [listen-handler]}]
(let [db-name (db-conn-state/get-repo-path repo)
db-conn (if (config/db-based-graph? repo)
(d/create-conn db-schema/schema)
(gp-db/start-conn))]
db-conn (d/create-conn db-schema/schema)]
(destroy-all!)
(swap! conns assoc db-name db-conn)
(when listen-handler

View File

@@ -7,14 +7,18 @@
[logseq.common.config :as common-config]
[logseq.common.util :as common-util]
[logseq.db :as ldb]
[logseq.graph-parser :as graph-parser]
[logseq.graph-parser.db :as gp-db]))
[logseq.graph-parser :as graph-parser]))
(defn get-page-file
[db page-name]
(some-> (ldb/get-page db page-name)
:block/file))
(defn- page-exists-in-another-file
"Conflict of files towards same page"
[db page file]
(when-let [page-name (:block/name page)]
(let [current-file (:file/path (gp-db/get-page-file db page-name))]
(let [current-file (:file/path (get-page-file db page-name))]
(when (not= file current-file)
current-file))))