Add filters for q and Q params
This commit is contained in:
parent
454643675f
commit
2464a66ac7
1 changed files with 32 additions and 0 deletions
32
src/rss_thread_watch/filters.clj
Normal file
32
src/rss_thread_watch/filters.clj
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
;; Copyright (C) 2024 Felisp
|
||||||
|
;;
|
||||||
|
;; This program is free software: you can redistribute it and/or modify
|
||||||
|
;; it under the terms of the GNU Affero General Public License as published by
|
||||||
|
;; the Free Software Foundation, version 3 of the License.
|
||||||
|
;;
|
||||||
|
;; This program is distributed in the hope that it will be useful,
|
||||||
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
;; GNU Affero General Public License for more details.
|
||||||
|
;;
|
||||||
|
;; You should have received a copy of the GNU Affero General Public License
|
||||||
|
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
(ns rss-thread-watch.filters
|
||||||
|
"Functions filtering posts"
|
||||||
|
(:require [clojure.string :as cs]
|
||||||
|
[rss-thread-watch.utils :as u])
|
||||||
|
(:gen-class))
|
||||||
|
|
||||||
|
(defn case-sensitive-filter
|
||||||
|
"Returns true if string [s] is matched by any query. It's case insensitive"
|
||||||
|
[s queries]
|
||||||
|
(some (fn [querry]
|
||||||
|
(cs/includes? s querry))
|
||||||
|
queries))
|
||||||
|
|
||||||
|
(defn case-insensitive-filter
|
||||||
|
"Returns true if string [s] is case-matched by query"
|
||||||
|
[s queries]
|
||||||
|
(basic-filter (cs/lower-case s) (cs/lower-case s)))
|
||||||
|
|
Loading…
Reference in a new issue