DB refactor and fix issues related to tags and aliases

1. add a `page` filter.
2. keep word case for both page and block's properties
3. remove `:tag/name` from the db schema

Fixed #1031
This commit is contained in:
Tienson Qin
2021-01-02 18:27:48 +08:00
parent 8f6d16d041
commit 48b6ccbdca
14 changed files with 158 additions and 202 deletions

View File

@@ -194,8 +194,7 @@
(defn with-page-refs
[{:keys [title body tags] :as block}]
(let [tags (mapv :tag/name (util/->tags (map :tag/name tags)))
ref-pages (atom tags)]
(let [ref-pages (atom tags)]
(walk/postwalk
(fn [form]
(when-let [page (get-page-reference form)]
@@ -254,12 +253,6 @@
(block-keywordize (util/remove-nils block)))
blocks))
(defn collect-block-tags
[{:keys [title body tags] :as block}]
(cond-> block
(seq tags)
(assoc :tags (util/->tags tags))))
(defn extract-blocks
[blocks last-pos encoded-content]
(let [blocks
@@ -319,7 +312,6 @@
block (if (seq timestamps)
(merge block (timestamps->scheduled-and-deadline timestamps))
block)
block (collect-block-tags block)
block (with-page-refs block)
block (with-block-refs block)
block (update-src-pos-meta! block)
@@ -382,8 +374,7 @@
blocks (doall
(map-indexed
(fn [idx {:block/keys [ref-pages ref-blocks meta] :as block}]
(let [block (collect-block-tags block)
block (merge
(let [block (merge
block
{:block/meta meta
:block/marker (get block :block/marker "nil")