Show subscriptions that ran in each epoch
This commit is contained in:
parent
ec242d53f5
commit
9e94099353
|
@ -125,6 +125,21 @@
|
|||
(= (:operation event)
|
||||
[:idle :add-event])))
|
||||
|
||||
(defn subscription? [trace]
|
||||
(= "sub" (namespace (:op-type trace))))
|
||||
|
||||
(defn subscription-created? [trace]
|
||||
(= :sub/create (:op-type trace)))
|
||||
|
||||
(defn subscription-re-run? [trace]
|
||||
(= :sub/run (:op-type trace)))
|
||||
|
||||
(defn subscription-destroyed? [trace]
|
||||
(= :sub/dispose (:op-type trace)))
|
||||
|
||||
(defn subscription-not-run? [trace]
|
||||
false)
|
||||
|
||||
(defn finish-run? [event]
|
||||
(and (fsm-trigger? event)
|
||||
(= (:operation event)
|
||||
|
|
|
@ -257,3 +257,86 @@
|
|||
:<- [:traces/current-event-traces]
|
||||
(fn [traces]
|
||||
(not (empty? traces))))
|
||||
|
||||
;;
|
||||
|
||||
(rf/reg-sub
|
||||
:subs/all-sub-traces
|
||||
:<- [:traces/current-event-traces]
|
||||
(fn [traces]
|
||||
(filter metam/subscription? traces)))
|
||||
|
||||
(defn sub-sort-val
|
||||
[sub]
|
||||
(case (:type sub)
|
||||
:created 1
|
||||
:re-run 2
|
||||
:destroyed 3
|
||||
:not-run 4))
|
||||
|
||||
(def subscription-comparator
|
||||
(fn [x y]
|
||||
(compare (sub-sort-val x) (sub-sort-val y))))
|
||||
|
||||
(defn sub-op-type->type [t]
|
||||
(case (:op-type t)
|
||||
:sub/create :created
|
||||
:sub/run :re-run
|
||||
:sub/dispose :destroyed
|
||||
|
||||
:not-run))
|
||||
|
||||
(rf/reg-sub
|
||||
:subs/all-subs
|
||||
:<- [:subs/all-sub-traces]
|
||||
(fn [traces]
|
||||
(let [raw [{:id (gensym) :type :destroyed :layer "3" :path "[:todo/blah]" :open? false :diff? false}
|
||||
{:id (gensym) :type :re-run :layer "2" :path "[:todo/blah]" :open? false :diff? false}
|
||||
{:id (gensym) :type :created :layer "3" :path "[:todo/completed]" :open? false :diff? true}
|
||||
{:id (gensym) :type :re-run :layer "3" :path "[:todo/completed]" :open? false :diff? false}
|
||||
{:id (gensym) :type :not-run :layer "3" :path "[:todo/blah]" :open? false :diff? false}]
|
||||
|
||||
raw (map (fn [trace] (let [pod-type (sub-op-type->type trace)
|
||||
path-str (pr-str (get-in trace [:tags :query-v]))]
|
||||
{:id (str pod-type path-str)
|
||||
:type pod-type
|
||||
:layer "2"
|
||||
:path path-str
|
||||
|
||||
;; TODO: data for sub
|
||||
;; TODO: get layer level
|
||||
;; TODO: Get not run subscriptions
|
||||
|
||||
:open? false
|
||||
:diff false}))
|
||||
traces)
|
||||
|
||||
run-multiple? (frequencies (map :path raw))]
|
||||
(js/console.log "Run Multiple" run-multiple?)
|
||||
(js/console.log "Traces" traces)
|
||||
(js/console.log "Raw" raw)
|
||||
(sort-by identity subscription-comparator raw))))
|
||||
|
||||
(rf/reg-sub
|
||||
:subs/created-count
|
||||
:<- [:subs/all-sub-traces]
|
||||
(fn [traces]
|
||||
(count (filter metam/subscription-created? traces))))
|
||||
|
||||
(rf/reg-sub
|
||||
:subs/re-run-count
|
||||
:<- [:subs/all-sub-traces]
|
||||
(fn [traces]
|
||||
(count (filter metam/subscription-re-run? traces))))
|
||||
|
||||
(rf/reg-sub
|
||||
:subs/destroyed-count
|
||||
:<- [:subs/all-sub-traces]
|
||||
(fn [traces]
|
||||
(count (filter metam/subscription-destroyed? traces))))
|
||||
|
||||
(rf/reg-sub
|
||||
:subs/not-run-count
|
||||
:<- [:subs/all-sub-traces]
|
||||
(fn [traces]
|
||||
(count (filter metam/subscription-not-run? traces))))
|
||||
|
|
|
@ -45,12 +45,16 @@
|
|||
:not-run "#bdbdbd"}]
|
||||
(get types type "black")))
|
||||
|
||||
(defn tag-desc [type]
|
||||
(let [types {:created {:long "CREATED" :short "CREATED"}
|
||||
(def tag-types {:created {:long "CREATED" :short "CREATED"}
|
||||
:destroyed {:long "DESTROYED" :short "DESTROY"}
|
||||
:re-run {:long "RE-RUN" :short "RE-RUN" }
|
||||
:not-run {:long "NOT-RUN" :short "NOT-RUN"}}]
|
||||
(get types type "???")))
|
||||
:re-run {:long "RE-RUN" :short "RE-RUN"}
|
||||
:not-run {:long "NOT-RUN" :short "NOT-RUN"}})
|
||||
|
||||
(defn long-tag-desc [type]
|
||||
(get-in tag-types [type :long] "???"))
|
||||
|
||||
(defn short-tag-desc [type]
|
||||
(get-in tag-types [type :short] "???"))
|
||||
|
||||
(defn tag [type label]
|
||||
[rc/box
|
||||
|
@ -73,6 +77,10 @@
|
|||
[tag type label]]])
|
||||
|
||||
(defn panel-header []
|
||||
(let [created-count (rf/subscribe [:subs/created-count])
|
||||
re-run-count (rf/subscribe [:subs/re-run-count])
|
||||
destroyed-count (rf/subscribe [:subs/destroyed-count])
|
||||
not-run-count (rf/subscribe [:subs/not-run-count])]
|
||||
[rc/h-box
|
||||
:justify :between
|
||||
:align :center
|
||||
|
@ -89,10 +97,10 @@
|
|||
:font-size "18px"
|
||||
:font-weight "lighter"}}
|
||||
"Summary:"]
|
||||
[title-tag :created (-> :created tag-desc :long) 2]
|
||||
[title-tag :re-run (-> :re-run tag-desc :long) 44]
|
||||
[title-tag :destroyed (-> :destroyed tag-desc :long) 1]
|
||||
[title-tag :not-run (-> :not-run tag-desc :long) 12]]]
|
||||
[title-tag :created (long-tag-desc :created) @created-count]
|
||||
[title-tag :re-run (long-tag-desc :re-run) @re-run-count]
|
||||
[title-tag :destroyed (long-tag-desc :destroyed) @destroyed-count]
|
||||
[title-tag :not-run (long-tag-desc :not-run) @not-run-count]]]
|
||||
[rc/h-box
|
||||
:align :center
|
||||
:gap common/gs-19s
|
||||
|
@ -105,7 +113,7 @@
|
|||
:model true
|
||||
:label [:span "Ignore unchanged" [:br] "layer 2 subs"]
|
||||
:style {:margin-top "6px"}
|
||||
:on-change #()]]]]])
|
||||
:on-change #()]]]]]))
|
||||
|
||||
(defn pod-header [{:keys [id type layer path open? diff?]}]
|
||||
[rc/h-box
|
||||
|
@ -129,7 +137,7 @@
|
|||
:child [:span.arrow (if open? "▼" "▶")]]]
|
||||
[rc/box
|
||||
:width "64px" ;; (100-36)px from box above
|
||||
:child [tag type (-> type tag-desc :short)]]
|
||||
:child [tag type (short-tag-desc type)]]
|
||||
[rc/h-box
|
||||
:size "auto"
|
||||
:class "app-db-path--path-header"
|
||||
|
@ -222,13 +230,14 @@
|
|||
:children [[rc/label :label "There are no subscriptions to show"]]])
|
||||
|
||||
(defn pod-section []
|
||||
(let [all-subs @(rf/subscribe [:subs/all-subs])]
|
||||
[rc/v-box
|
||||
:gap pod-gap
|
||||
:children (if (empty? @*pods)
|
||||
:children (if (empty? all-subs)
|
||||
[[no-pods]]
|
||||
(doall (for [p @*pods]
|
||||
^{:key (str p)}
|
||||
[pod p])))])
|
||||
(doall (for [p all-subs]
|
||||
^{:key (:id p)}
|
||||
[pod p])))]))
|
||||
|
||||
(defn render []
|
||||
[]
|
||||
|
|
Loading…
Reference in New Issue