mirror of https://github.com/logseq/logseq
fix: common test failing due to code organization
datascript based utils should be in db dep. common is for dependency free namespacespull/10981/head
parent
b050d478f6
commit
c660096937
|
@ -153,6 +153,7 @@
|
|||
logseq.db.frontend.property.type db-property-type
|
||||
logseq.db.frontend.property.util db-property-util
|
||||
logseq.db.frontend.entity-plus entity-plus
|
||||
logseq.db.frontend.entity-util entity-util
|
||||
logseq.db.frontend.rules rules
|
||||
logseq.db.frontend.schema db-schema
|
||||
logseq.db.frontend.validate db-validate
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
[logseq.common.log :as log]
|
||||
[goog.string :as gstring]
|
||||
[cljs-time.coerce :as tc]
|
||||
[cljs-time.core :as t]
|
||||
[datascript.core :as d]))
|
||||
[cljs-time.core :as t]))
|
||||
|
||||
(defn safe-decode-uri-component
|
||||
[uri]
|
||||
|
@ -348,9 +347,4 @@ return: [{:id 3} {:id 2 :depend-on 3} {:id 1 :depend-on 2}]"
|
|||
(let [rest-ids* (disj rest-ids id)]
|
||||
(vreset! seen-ids #{})
|
||||
(recur (conj r id) rest-ids* (first rest-ids*))))))]
|
||||
(mapv id->elem sorted-ids)))
|
||||
|
||||
(defn db-based-graph?
|
||||
"Whether the current graph is db-only"
|
||||
[db]
|
||||
(= "db" (:kv/value (d/entity db :logseq.kv/db-type))))
|
||||
(mapv id->elem sorted-ids)))
|
|
@ -8,7 +8,9 @@
|
|||
[logseq.common.util :as common-util]
|
||||
[logseq.common.uuid :as common-uuid]
|
||||
[logseq.db.frontend.delete-blocks :as delete-blocks]
|
||||
[logseq.db.frontend.entity-plus :as entity-plus]
|
||||
;; Load entity extensions
|
||||
[logseq.db.frontend.entity-plus]
|
||||
[logseq.db.frontend.entity-util :as entity-util]
|
||||
[logseq.db.frontend.rules :as rules]
|
||||
[logseq.db.sqlite.common-db :as sqlite-common-db]
|
||||
[logseq.db.sqlite.util :as sqlite-util]
|
||||
|
@ -175,7 +177,7 @@
|
|||
|
||||
(def get-first-page-by-name sqlite-common-db/get-first-page-by-name)
|
||||
|
||||
(def db-based-graph? entity-plus/db-based-graph?)
|
||||
(def db-based-graph? entity-util/db-based-graph?)
|
||||
|
||||
(defn page-exists?
|
||||
"Whether a page exists with the `type`."
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
(:require [clojure.string :as string]
|
||||
[logseq.common.util.page-ref :as page-ref]
|
||||
[datascript.core :as d]
|
||||
[logseq.common.util :as common-util]))
|
||||
[logseq.common.util :as common-util]
|
||||
[logseq.db.frontend.entity-util :as entity-util]))
|
||||
|
||||
(defonce page-ref-special-chars "~^")
|
||||
|
||||
|
@ -95,7 +96,7 @@
|
|||
(defn update-block-content
|
||||
"Replace `[[internal-id]]` with `[[page name]]`"
|
||||
[db item eid]
|
||||
(if (common-util/db-based-graph? db)
|
||||
(if (entity-util/db-based-graph? db)
|
||||
(if-let [content (:block/title item)]
|
||||
(let [refs (:block/refs (d/entity db eid))]
|
||||
(assoc item :block/title (special-id-ref->page-ref content refs)))
|
||||
|
@ -131,4 +132,4 @@
|
|||
(:block/uuid tag)
|
||||
page-ref/right-brackets)))
|
||||
content
|
||||
(sort-by :block/title > tags)))
|
||||
(sort-by :block/title > tags)))
|
|
@ -5,7 +5,7 @@
|
|||
[logseq.common.util.page-ref :as page-ref]
|
||||
[datascript.core :as d]
|
||||
[clojure.string :as string]
|
||||
[logseq.db.frontend.entity-plus :as entity-plus]
|
||||
[logseq.db.frontend.entity-util :as entity-util]
|
||||
[logseq.db.sqlite.util :as sqlite-util]
|
||||
[logseq.db.frontend.content :as db-content]))
|
||||
|
||||
|
@ -50,7 +50,7 @@
|
|||
(when (seq retracted-block-ids)
|
||||
(let [retracted-blocks (map #(d/entity db %) retracted-block-ids)
|
||||
retracted-tx (build-retracted-tx retracted-blocks)
|
||||
macros-tx (when-not (entity-plus/db-based-graph? db)
|
||||
macros-tx (when-not (entity-util/db-based-graph? db)
|
||||
(mapcat (fn [b]
|
||||
;; Only delete if last reference
|
||||
(keep #(when (<= (count (:block/_macros (d/entity db (:db/id %))))
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
[datascript.impl.entity :as entity :refer [Entity]]
|
||||
[logseq.db.frontend.content :as db-content]
|
||||
[logseq.db.frontend.property :as db-property]
|
||||
[logseq.common.util :as common-util]))
|
||||
[logseq.db.frontend.entity-util :as entity-util]))
|
||||
|
||||
(def db-based-graph? common-util/db-based-graph?)
|
||||
(def db-based-graph? entity-util/db-based-graph?)
|
||||
|
||||
(def lookup-entity @#'entity/lookup-entity)
|
||||
(defn lookup-kv-then-entity
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
(ns logseq.db.frontend.entity-util
|
||||
"Lower level entity util fns used across db namespaces"
|
||||
(:require [datascript.core :as d]))
|
||||
|
||||
(defn db-based-graph?
|
||||
"Whether the current graph is db-only"
|
||||
[db]
|
||||
(= "db" (:kv/value (d/entity db :logseq.kv/db-type))))
|
|
@ -7,7 +7,7 @@
|
|||
[logseq.common.util.date-time :as date-time-util]
|
||||
[logseq.common.util :as common-util]
|
||||
[logseq.common.config :as common-config]
|
||||
[logseq.db.frontend.entity-plus :as entity-plus]
|
||||
[logseq.db.frontend.entity-util :as entity-util]
|
||||
[clojure.set :as set]
|
||||
[logseq.db.frontend.order :as db-order]))
|
||||
|
||||
|
@ -81,7 +81,7 @@
|
|||
|
||||
(defn- property-with-values
|
||||
[db block]
|
||||
(when (entity-plus/db-based-graph? db)
|
||||
(when (entity-util/db-based-graph? db)
|
||||
(let [block (d/entity db (:db/id block))]
|
||||
(->> (:block/properties block)
|
||||
vals
|
||||
|
@ -250,7 +250,7 @@
|
|||
"Returns current database schema and initial data.
|
||||
NOTE: This fn is called by DB and file graphs"
|
||||
[db]
|
||||
(let [db-graph? (entity-plus/db-based-graph? db)
|
||||
(let [db-graph? (entity-util/db-based-graph? db)
|
||||
_ (when db-graph?
|
||||
(reset! db-order/*max-key (db-order/get-max-order db)))
|
||||
schema (:schema db)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
[logseq.db.frontend.rules :as rules]
|
||||
[clojure.set :as set]
|
||||
[clojure.string :as string]
|
||||
[logseq.db.frontend.entity-plus :as entity-plus]
|
||||
[logseq.db.frontend.entity-util :as entity-util]
|
||||
[logseq.db.frontend.property :as db-property]))
|
||||
|
||||
(defn ^:api get-area-block-asset-url
|
||||
|
@ -13,7 +13,7 @@
|
|||
[db block page]
|
||||
(when-some [props (and block page (:block/properties block))]
|
||||
;; Can't use db-property-util/lookup b/c repo isn't available
|
||||
(let [prop-lookup-fn (if (entity-plus/db-based-graph? db)
|
||||
(let [prop-lookup-fn (if (entity-util/db-based-graph? db)
|
||||
#(db-property/property-value-content (get %1 %2))
|
||||
#(get %1 (keyword (name %2))))]
|
||||
(when-some [uuid (:block/uuid block)]
|
||||
|
@ -104,7 +104,7 @@
|
|||
|
||||
(defn- hl-type-area-fn
|
||||
[db]
|
||||
(if (entity-plus/db-based-graph? db)
|
||||
(if (entity-util/db-based-graph? db)
|
||||
(fn [datom]
|
||||
(and (= :logseq.property/hl-type (:a datom))
|
||||
(= (keyword (:v datom)) :area)))
|
||||
|
|
Loading…
Reference in New Issue