Make filters take the whole thread to be more flexible

This commit is contained in:
Felisp 2024-09-24 00:27:16 +02:00
parent 817790cfb4
commit 8d61968dc9
2 changed files with 5 additions and 5 deletions

View file

@ -64,7 +64,7 @@
(let [filterable (select-keys query-string (let [filterable (select-keys query-string
(keys known-filter-map))] (keys known-filter-map))]
(ut/fkmap (fn [k v] (ut/fkmap (fn [k v]
{(get known-filter-map k) v}) {(get known-filter-map k) (ut/vectorize v)})
filterable))) filterable)))
(defn filter-chod-posts (defn filter-chod-posts

View file

@ -20,15 +20,15 @@
(defn case-sensitive-filter (defn case-sensitive-filter
"Returns true if string [s] is matched by any query. It's case insensitive" "Returns true if string [s] is matched by any query. It's case insensitive"
[s queries] [{:keys [title]} queries]
(some (fn [querry] (some (fn [querry]
(cs/includes? s querry)) (cs/includes? title querry))
queries)) queries))
(defn case-insensitive-filter (defn case-insensitive-filter
"Returns true if string [s] is case-matched by query" "Returns true if string [s] is case-matched by query"
[s queries] [{:keys [title]} queries]
(case-sensitive-filter (cs/lower-case s) (map cs/lower-case queries))) (case-sensitive-filter {:title (cs/lower-case title)} (map cs/lower-case queries)))
(def known-filters (def known-filters
{"Q" case-sensitive-filter {"Q" case-sensitive-filter