mirror of
https://github.com/status-im/open-bounty.git
synced 2025-02-17 11:56:30 +00:00
reformat bounty-filter-types-def
This commit is contained in:
parent
fa5bdef66a
commit
65cea5d521
@ -108,7 +108,7 @@
|
|||||||
|
|
||||||
(defmethod bounties-filter-tooltip-view ::ui-model/bounty-filter-type-category|multiple-dynamic-options
|
(defmethod bounties-filter-tooltip-view ::ui-model/bounty-filter-type-category|multiple-dynamic-options
|
||||||
[filter-type filter-type-def current-filter-value tooltip-open?]
|
[filter-type filter-type-def current-filter-value tooltip-open?]
|
||||||
(let [options (rf/subscribe [(::ui-model/bounty-filter-type.re-frame-subscription-key-for-options filter-type-def)])]
|
(let [options (rf/subscribe [(::ui-model/bounty-filter-type.re-frame-subs-key-for-options filter-type-def)])]
|
||||||
[:div.open-bounties-filter-list
|
[:div.open-bounties-filter-list
|
||||||
(for [option @options]
|
(for [option @options]
|
||||||
(let [active? (boolean (and current-filter-value (current-filter-value option)))]
|
(let [active? (boolean (and current-filter-value (current-filter-value option)))]
|
||||||
|
@ -45,42 +45,49 @@
|
|||||||
(def bounty-filter-type-date-options (keys bounty-filter-type-date-options-def))
|
(def bounty-filter-type-date-options (keys bounty-filter-type-date-options-def))
|
||||||
|
|
||||||
(def bounty-filter-types-def
|
(def bounty-filter-types-def
|
||||||
{::bounty-filter-type|value {::bounty-filter-type.name "Value"
|
{::bounty-filter-type|value
|
||||||
::bounty-filter-type.category ::bounty-filter-type-category|range
|
{::bounty-filter-type.name "Value"
|
||||||
::bounty-filter-type.min-val 0
|
::bounty-filter-type.category ::bounty-filter-type-category|range
|
||||||
::bounty-filter-type.max-val 1000
|
::bounty-filter-type.min-val 0
|
||||||
::bounty-filter-type.predicate (fn [filter-value bounty]
|
::bounty-filter-type.max-val 1000
|
||||||
(let [min-val (first filter-value)
|
::bounty-filter-type.predicate (fn [filter-value bounty]
|
||||||
max-val (second filter-value)]
|
(let [min-val (first filter-value)
|
||||||
(<= min-val (:value-usd bounty) max-val)))}
|
max-val (second filter-value)]
|
||||||
::bounty-filter-type|currency {::bounty-filter-type.name "Currency"
|
(<= min-val (:value-usd bounty) max-val)))}
|
||||||
::bounty-filter-type.category ::bounty-filter-type-category|multiple-dynamic-options
|
|
||||||
::bounty-filter-type.re-frame-subscription-key-for-options :commiteth.subscriptions/open-bounties-currencies
|
::bounty-filter-type|currency
|
||||||
::bounty-filter-type.predicate (fn [filter-value bounty]
|
{::bounty-filter-type.name "Currency"
|
||||||
(and (or (not-any? #{"ETH"} filter-value)
|
::bounty-filter-type.category ::bounty-filter-type-category|multiple-dynamic-options
|
||||||
(< 0 (:balance-eth bounty)))
|
::bounty-filter-type.re-frame-subs-key-for-options :commiteth.subscriptions/open-bounties-currencies
|
||||||
(set/subset? (->> filter-value (remove #{"ETH"}) set)
|
::bounty-filter-type.predicate (fn [filter-value bounty]
|
||||||
(-> bounty :tokens keys set))))}
|
(and (or (not-any? #{"ETH"} filter-value)
|
||||||
::bounty-filter-type|date {::bounty-filter-type.name "Date"
|
(< 0 (:balance-eth bounty)))
|
||||||
::bounty-filter-type.category ::bounty-filter-type-category|single-static-option
|
(set/subset? (->> filter-value (remove #{"ETH"}) set)
|
||||||
::bounty-filter-type.options bounty-filter-type-date-options-def
|
(-> bounty :tokens keys set))))}
|
||||||
::bounty-filter-type.pre-predicate-value-processor (fn [filter-value]
|
|
||||||
(let [filter-from (condp = filter-value
|
::bounty-filter-type|date
|
||||||
::bounty-filter-type-date-option|last-week (t/minus (t/now) (t/weeks 1))
|
{::bounty-filter-type.name "Date"
|
||||||
::bounty-filter-type-date-option|last-month (t/minus (t/now) (t/months 1))
|
::bounty-filter-type.category ::bounty-filter-type-category|single-static-option
|
||||||
::bounty-filter-type-date-option|last-3-months (t/minus (t/now) (t/months 3)))]
|
::bounty-filter-type.options bounty-filter-type-date-options-def
|
||||||
(t/interval filter-from (t/now))))
|
::bounty-filter-type.pre-predicate-value-processor (fn [filter-value]
|
||||||
::bounty-filter-type.predicate (fn [filter-value-interval bounty]
|
(let [filter-from (condp = filter-value
|
||||||
(when-let [created-at-inst (:created-at bounty)]
|
::bounty-filter-type-date-option|last-week (t/minus (t/now) (t/weeks 1))
|
||||||
(let [created-at-date (-> created-at-inst inst-ms t-coerce/from-long)]
|
::bounty-filter-type-date-option|last-month (t/minus (t/now) (t/months 1))
|
||||||
(t/within? filter-value-interval created-at-date))))}
|
::bounty-filter-type-date-option|last-3-months (t/minus (t/now) (t/months 3)))]
|
||||||
::bounty-filter-type|owner {::bounty-filter-type.name "Owner"
|
(t/interval filter-from (t/now))))
|
||||||
::bounty-filter-type.category ::bounty-filter-type-category|multiple-dynamic-options
|
::bounty-filter-type.predicate (fn [filter-value-interval bounty]
|
||||||
::bounty-filter-type.re-frame-subscription-key-for-options :commiteth.subscriptions/open-bounties-owners
|
(when-let [created-at-inst (:created-at bounty)]
|
||||||
::bounty-filter-type.predicate (fn [filter-value bounty]
|
(let [created-at-date (-> created-at-inst inst-ms t-coerce/from-long)]
|
||||||
(->> filter-value
|
(t/within? filter-value-interval created-at-date))))}
|
||||||
(some #{(:repo-owner bounty)})
|
|
||||||
boolean))}})
|
::bounty-filter-type|owner
|
||||||
|
{::bounty-filter-type.name "Owner"
|
||||||
|
::bounty-filter-type.category ::bounty-filter-type-category|multiple-dynamic-options
|
||||||
|
::bounty-filter-type.re-frame-subs-key-for-options :commiteth.subscriptions/open-bounties-owners
|
||||||
|
::bounty-filter-type.predicate (fn [filter-value bounty]
|
||||||
|
(->> filter-value
|
||||||
|
(some #{(:repo-owner bounty)})
|
||||||
|
boolean))}})
|
||||||
|
|
||||||
(def bounty-filter-types (keys bounty-filter-types-def))
|
(def bounty-filter-types (keys bounty-filter-types-def))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user