From 2e43db72e32cf089f1b8fc4864131bd00fe585b3 Mon Sep 17 00:00:00 2001 From: Filipe Silva Date: Thu, 15 Sep 2022 12:16:22 +0100 Subject: [PATCH] feat: athena searches breadcrumbs too --- src/cljs/athens/db.cljs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/cljs/athens/db.cljs b/src/cljs/athens/db.cljs index bedca1619f..79e0ba9f50 100644 --- a/src/cljs/athens/db.cljs +++ b/src/cljs/athens/db.cljs @@ -384,6 +384,15 @@ :else nil)))) +(defn parent-block-strings + [db eid] + (->> eid + (common-db/get-parent-eids db) + reverse + (mapv (partial d/entity db)) + (mapv #(or (:block/string %) (:node/title %))))) + + (defn search-in-block-content ([query] (search-in-block-content query 20)) ([query n] @@ -395,7 +404,10 @@ (d/datoms db :aevt :block/string) (sequence (comp - (filter #(re-find case-insensitive-query (:v %))) + (filter #(->> (:v %) + (conj (parent-block-strings db (:e %))) + (string/join " ") + (re-find case-insensitive-query))) (take n) (map #(:e %)))) (d/pull-many db '[:db/id :block/uid :block/string :node/title