Make subscription counts match visible pods

This commit is contained in:
Daniel Compton 2018-01-18 15:12:59 +13:00
parent 6b4bf37a21
commit c236d1ff63
1 changed files with 20 additions and 13 deletions

View File

@ -360,30 +360,37 @@
(remove metam/unchanged-l2-subscription? all-subs) (remove metam/unchanged-l2-subscription? all-subs)
all-subs))) all-subs)))
(rf/reg-sub
:subs/sub-counts
:<- [:subs/visible-subs]
(fn [subs _]
(->> subs
(map :type)
(frequencies))))
(rf/reg-sub (rf/reg-sub
:subs/created-count :subs/created-count
:<- [:subs/all-sub-traces] :<- [:subs/sub-counts]
(fn [traces] (fn [counts]
(count (filter metam/subscription-created? traces)))) (get counts :created 0)))
(rf/reg-sub (rf/reg-sub
:subs/re-run-count :subs/re-run-count
:<- [:subs/all-sub-traces] :<- [:subs/sub-counts]
;; TODO: remove created subs that were re-run, they count as created only (fn [counts]
(fn [traces] (get counts :re-run 0)))
(count (filter metam/subscription-re-run? traces))))
(rf/reg-sub (rf/reg-sub
:subs/destroyed-count :subs/destroyed-count
:<- [:subs/all-sub-traces] :<- [:subs/sub-counts]
(fn [traces] (fn [counts]
(count (filter metam/subscription-destroyed? traces)))) (get counts :destroyed 0)))
(rf/reg-sub (rf/reg-sub
:subs/not-run-count :subs/not-run-count
:<- [:subs/all-sub-traces] :<- [:subs/sub-counts]
(fn [traces] (fn [counts]
(count (filter metam/subscription-not-run? traces)))) (get counts :not-run 0)))
(rf/reg-sub (rf/reg-sub
:subs/unchanged-l2-subs-count :subs/unchanged-l2-subs-count