a few improvements and comments in filter-bounties

This commit is contained in:
pablodip 2018-01-31 11:51:55 +01:00
parent 9b40abc1a1
commit fa5bdef66a
2 changed files with 6 additions and 5 deletions

View File

@ -162,6 +162,6 @@
:<- [::open-bounties-sorting-type]
(fn [[open-bounties filters sorting-type] _]
(cond->> open-bounties
filters (ui-model/filter-bounties filters)
true (ui-model/filter-bounties filters)
sorting-type (ui-model/sort-bounties-by-sorting-type sorting-type)
filter vec)))
true vec)))

View File

@ -107,15 +107,16 @@
(defn filter-bounties [filters-by-type bounties]
(let [filter-preds (->> filters-by-type
; used `nil?` because a valid filter value can be `false`
(remove #(nil? (val %)))
(map (fn [[filter-type filter-value]]
(let [filter-type-def (bounty-filter-types-def filter-type)
pred (::bounty-filter-type.predicate filter-type-def)
pre-pred-processor (::bounty-filter-type.pre-predicate-value-processor filter-type-def)
filter-value (cond-> filter-value
pre-pred-processor (pre-pred-processor filter-value))]
pre-pred-processor pre-pred-processor)]
(partial pred filter-value)))))
filters-pred (fn [bounty]
(every? #(% bounty) filter-preds))]
(->> bounties
(filter filters-pred))))
(cond->> bounties
(not-empty filter-preds) (filter filters-pred))))