|
@@ -199,9 +199,7 @@ Options available:
|
|
|
|
|
|
|
|
(defn import-file-to-db-graph
|
|
(defn import-file-to-db-graph
|
|
|
"Parse file and save parsed data to the given db graph."
|
|
"Parse file and save parsed data to the given db graph."
|
|
|
- [conn file content {:keys [delete-blocks-fn extract-options skip-db-transact?]
|
|
|
|
|
- :or {delete-blocks-fn (constantly [])
|
|
|
|
|
- skip-db-transact? false}
|
|
|
|
|
|
|
+ [conn file content {:keys [extract-options]
|
|
|
:as options}]
|
|
:as options}]
|
|
|
(let [format (common-util/get-format file)
|
|
(let [format (common-util/get-format file)
|
|
|
{:keys [tx ast]}
|
|
{:keys [tx ast]}
|
|
@@ -227,7 +225,6 @@ Options available:
|
|
|
;; remove file path relative
|
|
;; remove file path relative
|
|
|
pages (map #(dissoc % :block/file :block/properties) pages)
|
|
pages (map #(dissoc % :block/file :block/properties) pages)
|
|
|
block-ids (map (fn [block] {:block/uuid (:block/uuid block)}) blocks)
|
|
block-ids (map (fn [block] {:block/uuid (:block/uuid block)}) blocks)
|
|
|
- delete-blocks (delete-blocks-fn @conn (first pages) file block-ids)
|
|
|
|
|
block-refs-ids (->> (mapcat :block/refs blocks)
|
|
block-refs-ids (->> (mapcat :block/refs blocks)
|
|
|
(filter (fn [ref] (and (vector? ref)
|
|
(filter (fn [ref] (and (vector? ref)
|
|
|
(= :block/uuid (first ref)))))
|
|
(= :block/uuid (first ref)))))
|
|
@@ -263,12 +260,10 @@ Options available:
|
|
|
blocks (map #(update-imported-block conn %) blocks)
|
|
blocks (map #(update-imported-block conn %) blocks)
|
|
|
pages-index (map #(select-keys % [:block/name]) pages)]
|
|
pages-index (map #(select-keys % [:block/name]) pages)]
|
|
|
|
|
|
|
|
- {:tx (concat refs whiteboard-pages pages-index delete-blocks pages block-ids blocks)
|
|
|
|
|
|
|
+ {:tx (concat refs whiteboard-pages pages-index pages block-ids blocks)
|
|
|
:ast ast})
|
|
:ast ast})
|
|
|
tx' (common-util/fast-remove-nils tx)
|
|
tx' (common-util/fast-remove-nils tx)
|
|
|
- result (if skip-db-transact?
|
|
|
|
|
- tx'
|
|
|
|
|
- (d/transact! conn tx' (select-keys options [:new-graph? :from-disk?])))]
|
|
|
|
|
|
|
+ result (d/transact! conn tx' (select-keys options [:new-graph? :from-disk?]))]
|
|
|
{:tx-report result
|
|
{:tx-report result
|
|
|
:ast ast}))
|
|
:ast ast}))
|
|
|
|
|
|