Remove unused db-type being passed to start-conn

Also removed other unused db fns
This commit is contained in:
Gabriel Horner
2022-05-23 11:49:07 -04:00
parent 11d3d5b3cd
commit 5bce219ca4
6 changed files with 11 additions and 115 deletions

View File

@@ -38,28 +38,27 @@
[frontend.db.model
blocks-count blocks-count-cache clean-export! delete-blocks get-pre-block
delete-file! delete-file-blocks! delete-page-blocks delete-file-pages! delete-file-tx delete-files delete-pages-by-files
delete-file-blocks! delete-page-blocks delete-files delete-pages-by-files
filter-only-public-pages-and-blocks get-all-block-contents get-all-tagged-pages
get-all-templates get-block-and-children get-block-by-uuid get-block-children sort-by-left
get-block-parent get-block-parents parents-collapsed? get-block-referenced-blocks
get-block-children-ids get-block-immediate-children get-block-page
get-blocks-contents get-custom-css
get-date-scheduled-or-deadlines get-db-type
get-file-blocks get-file-contents get-file-last-modified-at get-file get-file-page get-file-page-id file-exists?
get-file-pages get-files get-files-blocks get-files-full get-journals-length
get-latest-journals get-matched-blocks get-page get-page-alias get-page-alias-names get-paginated-blocks get-page-linked-refs-refed-pages
get-custom-css get-date-scheduled-or-deadlines
get-file-blocks get-file-last-modified-at get-file get-file-page get-file-page-id file-exists?
get-files get-files-blocks get-files-full get-journals-length
get-latest-journals get-page get-page-alias get-page-alias-names get-paginated-blocks get-page-linked-refs-refed-pages
get-page-blocks-count get-page-blocks-no-cache get-page-file get-page-format get-page-properties
get-page-referenced-blocks get-page-referenced-pages get-page-unlinked-references get-page-referenced-blocks-no-cache
get-all-pages get-pages get-pages-relation get-pages-that-mentioned-page get-public-pages get-tag-pages
journal-page? page-alias-set pull-block
set-file-last-modified-at! transact-files-db! page-empty? page-exists? page-empty-or-dummy? get-alias-source-page
set-file-last-modified-at! page-empty? page-exists? page-empty-or-dummy? get-alias-source-page
set-file-content! has-children? get-namespace-pages get-all-namespace-relation get-pages-by-name-partition]
[frontend.db.react
get-current-page set-key-value
remove-key! remove-q! remove-query-component! add-q! add-query-component! clear-query-state!
clear-query-state-without-refs-and-embeds! kv q
query-state query-components query-entity-in-component remove-custom-query! set-new-result! sub-key-value refresh!]
query-state query-components remove-custom-query! set-new-result! sub-key-value refresh!]
[frontend.db.query-custom
custom-query]

View File

@@ -56,18 +56,6 @@
{:block/page [:db/id :block/name :block/original-name :block/journal-day]}
{:block/_parent ...}])
(defn transact-files-db!
([tx-data]
(db-utils/transact! (state/get-current-repo) tx-data))
([repo-url tx-data]
(when-not config/publishing?
(let [tx-data (->> (gp-util/remove-nils tx-data)
(remove nil?)
(map #(dissoc % :file/handle :file/type)))]
(when (seq tx-data)
(when-let [conn (conn/get-db repo-url false)]
(d/transact! conn (vec tx-data))))))))
(defn pull-block
[id]
(let [repo (state/get-current-repo)]
@@ -208,16 +196,6 @@
(conn/get-db repo-url) path)
db-utils/seq-flatten))
(defn get-file-pages
[repo-url path]
(-> (d/q '[:find ?page
:in $ ?path
:where
[?file :file/path ?path]
[?page :block/file ?file]]
(conn/get-db repo-url) path)
db-utils/seq-flatten))
(defn set-file-last-modified-at!
[repo path last-modified-at]
(when (and repo path last-modified-at)
@@ -240,19 +218,6 @@
(when-let [db (conn/get-db repo)]
(d/entity db [:file/path path]))))
(defn get-file-contents
[repo]
(when-let [db (conn/get-db repo)]
(->>
(d/q
'[:find ?path ?content
:where
[?file :file/path ?path]
[?file :file/content ?content]]
db)
(into {}))))
(defn get-files-full
[repo]
(when-let [db (conn/get-db repo)]
@@ -1303,43 +1268,11 @@
(get-block-referenced-blocks-ids id)
(get-page-referenced-blocks-ids page-name-or-block-uuid)))
(defn get-matched-blocks
[match-fn limit]
(when-let [repo (state/get-current-repo)]
(let [pred (fn [_db content]
(match-fn content))]
(->> (d/q
'[:find ?block
:in $ ?pred
:where
[?block :block/content ?content]
[(?pred $ ?content)]]
(conn/get-db)
pred)
(take limit)
db-utils/seq-flatten
(db-utils/pull-many '[:block/uuid
:block/content
:block/properties
:block/format
{:block/page [:block/name]}])))))
;; TODO: Does the result preserves the order of the arguments?
(defn get-blocks-contents
[repo block-uuids]
(let [db (conn/get-db repo)]
(db-utils/pull-many repo '[:block/content]
(mapv (fn [id] [:block/uuid id]) block-uuids))))
(defn journal-page?
"sanitized page-name only"
[page-name]
(:block/journal? (db-utils/entity [:block/name page-name])))
(defn get-db-type
[repo]
(db-utils/get-key-value repo :db/type))
(defn get-public-pages
[db]
(-> (d/q
@@ -1514,24 +1447,6 @@
block-eids (mapv :e datoms)]
(mapv (fn [eid] [:db.fn/retractEntity eid]) block-eids)))))))
(defn delete-file-pages!
[repo-url path]
(let [pages (get-file-pages repo-url path)]
(mapv (fn [eid] [:db.fn/retractEntity eid]) pages)))
(defn delete-file-tx
[repo-url file-path]
(->>
(concat
(delete-file-blocks! repo-url file-path)
(delete-file-pages! repo-url file-path)
[[:db.fn/retractEntity [:file/path file-path]]])
(remove nil?)))
(defn delete-file!
[repo-url file-path]
(db-utils/transact! repo-url (delete-file-tx repo-url file-path)))
(defn delete-pages-by-files
[files]
(let [pages (->> (mapv get-file-page files)

View File

@@ -137,21 +137,6 @@
;; Reactive query
(defn query-entity-in-component
([id-or-lookup-ref]
(db-utils/entity (state/get-current-repo) id-or-lookup-ref))
([repo id-or-lookup-ref]
(let [k [:entity id-or-lookup-ref]
result-atom (:result (get @query-state k))]
(when-let [component *query-component*]
(add-query-component! k component))
(when-let [db (conn/get-db repo)]
(let [result (d/entity db id-or-lookup-ref)
result-atom (or result-atom (atom nil))]
(set! (.-state result-atom) result)
(add-q! k nil nil result-atom identity identity identity))))))
(defn get-query-cached-result
[k]
(:result (get @query-state k)))

View File

@@ -354,9 +354,9 @@
(delete-db-f)))))
(defn start-repo-db-if-not-exists!
[repo option]
[repo]
(state/set-current-repo! repo)
(db/start-db-conn! repo option))
(db/start-db-conn! repo))
(defn setup-local-repo-if-not-exists!
[]

View File

@@ -174,7 +174,7 @@
(assoc file :file/content content))) markup-files))
(p/then (fn [result]
(let [files (map #(dissoc % :file/file) result)]
(repo-handler/start-repo-db-if-not-exists! repo {:db-type :local-native-fs})
(repo-handler/start-repo-db-if-not-exists! repo)
(async/go
(let [_finished? (async/<! (repo-handler/load-repo-to-db! repo
{:new-graph? true

View File

@@ -7,10 +7,7 @@
"Create datascript conn with schema and default data"
[]
(let [db-conn (d/create-conn db-schema/schema)]
(d/transact! db-conn [(cond-> {:schema/version db-schema/version}
;; TODO: Handle this
#_db-type
#_(assoc :db/type db-type))
(d/transact! db-conn [{:schema/version db-schema/version}
{:block/name "card"
:block/original-name "card"
:block/uuid (d/squuid)}])