Selaa lähdekoodia

fix: search-block-aux typo

Junyi Du 3 vuotta sitten
vanhempi
sitoutus
4c6bf7aced
1 muutettua tiedostoa jossa 10 lisäystä ja 3 poistoa
  1. 10 3
      src/electron/electron/search.cljs

+ 10 - 3
src/electron/electron/search.cljs

@@ -273,17 +273,23 @@
         (->>
          (concat matched-result
                  (search-blocks-aux database non-match-sql non-match-input page limit))
-         (distinct-by :id)
+         (distinct-by :rowid)
          (take limit)
          (vec))))))
 
+(defn- snippet-by
+  [content length]
+  (str (subs content 0 length) "..."))
+
 (defn- search-pages-res-unpack
   [arr]
   (let [[rowid uuid content snippet] arr]
     {:id      rowid
      :uuid    uuid
      :content content
-     :snippet snippet}))
+     :snippet (if (string/includes? snippet "$pfts_2lqh>$ ")
+                snippet
+                (snippet-by snippet 250))}))
 
 (defn- search-pages-aux
   [database sql input limit]
@@ -317,7 +323,8 @@
                               match-inputs)
                             (apply concat))]
         (->>
-         matched-result
+         (concat matched-result
+                 (search-pages-aux database non-match-sql non-match-input limit))
          (distinct-by :id)
          (take limit)
          (vec))))))