diff --git a/src/electron/electron/search.cljs b/src/electron/electron/search.cljs index 22964e665..7671b5008 100644 --- a/src/electron/electron/search.cljs +++ b/src/electron/electron/search.cljs @@ -169,7 +169,8 @@ [repo pages] (if-let [db (get-db repo)] ;; TODO: what if a CONFLICT on uuid - (let [insert (prepare db "INSERT INTO pages (id, uuid, content) VALUES (@id, @uuid, @content) ON CONFLICT (id) DO UPDATE SET content = @content") + ;; Should update all values on id conflict + (let [insert (prepare db "INSERT INTO pages (id, uuid, content) VALUES (@id, @uuid, @content) ON CONFLICT (id) DO UPDATE SET (uuid, content) = (@uuid, @content)") insert-many (.transaction ^object db (fn [pages] (doseq [page pages] @@ -190,7 +191,8 @@ [repo blocks] (if-let [db (get-db repo)] ;; TODO: what if a CONFLICT on uuid - (let [insert (prepare db "INSERT INTO blocks (id, uuid, content, page) VALUES (@id, @uuid, @content, @page) ON CONFLICT (id) DO UPDATE SET content = @content") + ;; Should update all values on id conflict + (let [insert (prepare db "INSERT INTO blocks (id, uuid, content, page) VALUES (@id, @uuid, @content, @page) ON CONFLICT (id) DO UPDATE SET (uuid, content, page) = (@uuid, @content, @page)") insert-many (.transaction ^object db (fn [blocks] (doseq [block blocks] diff --git a/src/main/frontend/components/search.cljs b/src/main/frontend/components/search.cljs index 0feaeee95..3042fcbc5 100644 --- a/src/main/frontend/components/search.cljs +++ b/src/main/frontend/components/search.cljs @@ -331,6 +331,8 @@ nil)])) (rum/defc search-auto-complete + "has-more? - if the result is truncated + all? - if true, in show-more mode" [{:keys [engine pages files pages-content blocks has-more?] :as result} search-q all?] (let [pages (when-not all? (map (fn [page] (let [alias (model/get-redirect-page-name page)] diff --git a/src/main/frontend/handler/search.cljs b/src/main/frontend/handler/search.cljs index 818459870..4a75c1a17 100644 --- a/src/main/frontend/handler/search.cljs +++ b/src/main/frontend/handler/search.cljs @@ -27,6 +27,7 @@ (text/remove-level-spaces content format (config/get-block-pattern format))) (defn search + "The aggretation of search results" ([q] (search (state/get-current-repo) q)) ([repo q] diff --git a/src/main/frontend/search.cljs b/src/main/frontend/search.cljs index 6b6fed4f9..d177e6e37 100644 --- a/src/main/frontend/search.cljs +++ b/src/main/frontend/search.cljs @@ -111,6 +111,9 @@ (protocol/transact-blocks! engine data))) (defn- transact-pages! + "Transact pages to search engine + :pages-to-remove-set the set of pages to remove (not include those to update) + :pages-to-add the page entities to add" [repo data] (when-let [engine (get-engine repo)] (protocol/transact-pages! engine data)))