Compare commits

..

No commits in common. "5178ab7366e2f32c611346a62bb827e80a0db25a" and "ee3ad0a6e91d727b12a383d84bb0ce17bcb681c4" have entirely different histories.

2 changed files with 35 additions and 12 deletions

View file

@ -58,14 +58,41 @@
(:chod thread)))) (:chod thread))))
(defn make-filters (defn make-filters
"Creates map of functions and filters from query string. "Creates map of functions and filters from query string"
Return format is: {filter-fun ['words' 'to' 'filter' 'using this function]}" ;; In future predicates could return matched parts of string instead of
[query-string known-filter-map] ;; t/nil values which could be used for coloring of results
(let [filterable (select-keys query-string [query-map]
(keys known-filter-map))] (let [filtering-params '("q" "Q") ;Later add "r" for regex
filter-map (select-keys query-map filtering-params)]
(ut/fkmap (fn [k v] (ut/fkmap (fn [k v]
{(get known-filter-map k) v}) {(case k
filterable))) ;; regex filter here
"q" f/case-insensitive-filter
"Q" f/case-sensitive-filter) v})
filter-map)))
(defn x [cache filters]
;;must return fitlered cache
;; {fun [key dfe dw kwd"]}
(filter
(fn [thread]
;; run every function for each thread
(let [title (get thread :title)]
(some (fn [filter]
(let [queries (get filters filter)]
(some (fn [q]
(filter title queries))
queries)
;; some again?
;; try some-map?
))
(keys filters)))
;;RESUME
) cache
))
(defn filter-chod-posts (defn filter-chod-posts
"Return list of all threads with equal or higher ChoD than requested "Return list of all threads with equal or higher ChoD than requested

View file

@ -28,9 +28,5 @@
(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] [s queries]
(case-sensitive-filter (cs/lower-case s) (map cs/lower-case queries))) (basic-filter (cs/lower-case s) (cs/lower-case s)))
(def known-filters
{"Q" case-sensitive-filter
"q" case-insensitive-filter})