Add date: matcher

This commit is contained in:
arne 2025-11-22 13:14:54 +01:00
commit d830e52b52

View file

@ -45,6 +45,12 @@
(defn date-after-matcher [term] (defn date-after-matcher [term]
(filter #(> (j/get % :created_at) term))) (filter #(> (j/get % :created_at) term)))
(defn date-on-matcher [term]
(let [date-parts (str/split term #"-")
x (parse-long (last date-parts))]
(comp (date-after-matcher term)
(date-before-matcher (str/join "-" (conj (vec (butlast date-parts)) (inc x)))))))
(defn token->term [token] (defn token->term [token]
(str/replace token #"^\w+:" "")) (str/replace token #"^\w+:" ""))
@ -58,6 +64,7 @@
(str/starts-with? token "to:") (mention-matcher (token->term token)) (str/starts-with? token "to:") (mention-matcher (token->term token))
(str/starts-with? token "before:") (date-before-matcher (token->term token)) (str/starts-with? token "before:") (date-before-matcher (token->term token))
(str/starts-with? token "after:") (date-after-matcher (token->term token)) (str/starts-with? token "after:") (date-after-matcher (token->term token))
(str/starts-with? token "date:")(date-on-matcher (token->term token))
:else (text-matcher token)))) :else (text-matcher token))))
(reduce comp)) (reduce comp))
(filter (constantly true)))) (filter (constantly true))))