Add setting to ignore unchanged layer 2 subscriptions
This commit is contained in:
parent
b07514d001
commit
18d0a9b145
|
@ -24,4 +24,5 @@
|
||||||
(rf/dispatch [:traces/update-show-epoch-traces? true]) ;; TODO: source this from LS.
|
(rf/dispatch [:traces/update-show-epoch-traces? true]) ;; TODO: source this from LS.
|
||||||
(rf/dispatch [:app-db/paths app-db-paths])
|
(rf/dispatch [:app-db/paths app-db-paths])
|
||||||
(rf/dispatch [:app-db/set-json-ml-paths json-ml-paths])
|
(rf/dispatch [:app-db/set-json-ml-paths json-ml-paths])
|
||||||
(rf/dispatch [:global/add-unload-hook])))
|
(rf/dispatch [:global/add-unload-hook])
|
||||||
|
(rf/dispatch [:app-db/reagent-id])))
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[goog.object]
|
[goog.object]
|
||||||
[re-frame.db]
|
[re-frame.db]
|
||||||
|
[re-frame.interop]
|
||||||
[day8.re-frame.trace.view.container :as container]
|
[day8.re-frame.trace.view.container :as container]
|
||||||
[day8.re-frame.trace.styles :as styles]
|
[day8.re-frame.trace.styles :as styles]
|
||||||
[clojure.set :as set]
|
[clojure.set :as set]
|
||||||
|
@ -399,6 +400,12 @@
|
||||||
(localstorage/save! "app-db-json-ml-expansions" new-paths)
|
(localstorage/save! "app-db-json-ml-expansions" new-paths)
|
||||||
new-paths)))
|
new-paths)))
|
||||||
|
|
||||||
|
(rf/reg-event-db
|
||||||
|
:app-db/reagent-id
|
||||||
|
[(rf/path [:app-db :reagent-id])]
|
||||||
|
(fn [paths _]
|
||||||
|
(re-frame.interop/reagent-id re-frame.db/app-db)))
|
||||||
|
|
||||||
(rf/reg-event-db
|
(rf/reg-event-db
|
||||||
:snapshot/load-snapshot
|
:snapshot/load-snapshot
|
||||||
(fn [db [_ new-db]]
|
(fn [db [_ new-db]]
|
||||||
|
@ -432,3 +439,11 @@
|
||||||
[(rf/path [:traces :all-traces])]
|
[(rf/path [:traces :all-traces])]
|
||||||
(fn [_ [_ traces]]
|
(fn [_ [_ traces]]
|
||||||
traces))
|
traces))
|
||||||
|
|
||||||
|
;;
|
||||||
|
|
||||||
|
(rf/reg-event-db
|
||||||
|
:subs/ignore-unchanged-subs?
|
||||||
|
[(rf/path [:subs :ignore-unchanged-subs?])]
|
||||||
|
(fn [_ [_ ignore?]]
|
||||||
|
ignore?))
|
||||||
|
|
|
@ -126,10 +126,12 @@
|
||||||
[:idle :add-event])))
|
[:idle :add-event])))
|
||||||
|
|
||||||
(defn subscription? [trace]
|
(defn subscription? [trace]
|
||||||
(= "sub" (namespace (:op-type trace))))
|
(and (= "sub" (namespace (:op-type trace)))
|
||||||
|
(not (get-in trace [:tags :cached?]))))
|
||||||
|
|
||||||
(defn subscription-created? [trace]
|
(defn subscription-created? [trace]
|
||||||
(= :sub/create (:op-type trace)))
|
(and (= :sub/create (:op-type trace))
|
||||||
|
(not (get-in trace [:tags :cached?]))))
|
||||||
|
|
||||||
(defn subscription-re-run? [trace]
|
(defn subscription-re-run? [trace]
|
||||||
(= :sub/run (:op-type trace)))
|
(= :sub/run (:op-type trace)))
|
||||||
|
@ -140,6 +142,13 @@
|
||||||
(defn subscription-not-run? [trace]
|
(defn subscription-not-run? [trace]
|
||||||
false)
|
false)
|
||||||
|
|
||||||
|
(defn unchanged-l2-subscription? [sub]
|
||||||
|
;; TODO: check if value changed
|
||||||
|
(and
|
||||||
|
(= :re-run (:type sub))
|
||||||
|
(= 2 (:layer sub))))
|
||||||
|
|
||||||
|
|
||||||
(defn finish-run? [event]
|
(defn finish-run? [event]
|
||||||
(and (fsm-trigger? event)
|
(and (fsm-trigger? event)
|
||||||
(= (:operation event)
|
(= (:operation event)
|
||||||
|
|
|
@ -78,6 +78,12 @@
|
||||||
(fn [expansions [_ path]]
|
(fn [expansions [_ path]]
|
||||||
(contains? expansions path)))
|
(contains? expansions path)))
|
||||||
|
|
||||||
|
(rf/reg-sub
|
||||||
|
:app-db/reagent-id
|
||||||
|
:<- [:app-db/root]
|
||||||
|
(fn [root _]
|
||||||
|
(:reagent-id root)))
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(rf/reg-sub
|
(rf/reg-sub
|
||||||
|
@ -260,6 +266,11 @@
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
(rf/reg-sub
|
||||||
|
:subs/root
|
||||||
|
(fn [db _]
|
||||||
|
(:subs db)))
|
||||||
|
|
||||||
(rf/reg-sub
|
(rf/reg-sub
|
||||||
:subs/all-sub-traces
|
:subs/all-sub-traces
|
||||||
:<- [:traces/current-event-traces]
|
:<- [:traces/current-event-traces]
|
||||||
|
@ -289,19 +300,19 @@
|
||||||
(rf/reg-sub
|
(rf/reg-sub
|
||||||
:subs/all-subs
|
:subs/all-subs
|
||||||
:<- [:subs/all-sub-traces]
|
:<- [:subs/all-sub-traces]
|
||||||
(fn [traces]
|
:<- [:app-db/reagent-id]
|
||||||
(let [raw [{:id (gensym) :type :destroyed :layer "3" :path "[:todo/blah]" :open? false :diff? false}
|
(fn [[traces app-db-id]]
|
||||||
{:id (gensym) :type :re-run :layer "2" :path "[:todo/blah]" :open? false :diff? false}
|
(js/console.log "appdb id" app-db-id)
|
||||||
{:id (gensym) :type :created :layer "3" :path "[:todo/completed]" :open? false :diff? true}
|
(let [raw (map (fn [trace] (let [pod-type (sub-op-type->type trace)
|
||||||
{:id (gensym) :type :re-run :layer "3" :path "[:todo/completed]" :open? false :diff? false}
|
path-str (pr-str (get-in trace [:tags :query-v]))
|
||||||
{:id (gensym) :type :not-run :layer "3" :path "[:todo/blah]" :open? false :diff? false}]
|
layer (if (some #(= app-db-id %) (get-in trace [:tags :input-signals]))
|
||||||
|
2
|
||||||
raw (map (fn [trace] (let [pod-type (sub-op-type->type trace)
|
3)]
|
||||||
path-str (pr-str (get-in trace [:tags :query-v]))]
|
{:id (str pod-type (get-in trace [:tags :reaction]))
|
||||||
{:id (str pod-type path-str)
|
|
||||||
:type pod-type
|
:type pod-type
|
||||||
:layer "2"
|
:layer layer
|
||||||
:path path-str
|
:path path-str
|
||||||
|
:value (get-in trace [:tags :value])
|
||||||
|
|
||||||
;; TODO: data for sub
|
;; TODO: data for sub
|
||||||
;; TODO: get layer level
|
;; TODO: get layer level
|
||||||
|
@ -311,12 +322,24 @@
|
||||||
:diff false}))
|
:diff false}))
|
||||||
traces)
|
traces)
|
||||||
|
|
||||||
run-multiple? (frequencies (map :path raw))]
|
;; Filter out run if it was created
|
||||||
|
;; Group together run time
|
||||||
|
|
||||||
|
run-multiple? (frequencies (map :id raw))]
|
||||||
(js/console.log "Run Multiple" run-multiple?)
|
(js/console.log "Run Multiple" run-multiple?)
|
||||||
(js/console.log "Traces" traces)
|
(js/console.log "Traces" traces)
|
||||||
(js/console.log "Raw" raw)
|
(js/console.log "Raw" raw)
|
||||||
(sort-by identity subscription-comparator raw))))
|
(sort-by identity subscription-comparator raw))))
|
||||||
|
|
||||||
|
(rf/reg-sub
|
||||||
|
:subs/visible-subs
|
||||||
|
:<- [:subs/all-subs]
|
||||||
|
:<- [:subs/ignore-unchanged-subs?]
|
||||||
|
(fn [[all-subs ignore-unchanged-l2?]]
|
||||||
|
(if ignore-unchanged-l2?
|
||||||
|
(remove metam/unchanged-l2-subscription? all-subs)
|
||||||
|
all-subs)))
|
||||||
|
|
||||||
(rf/reg-sub
|
(rf/reg-sub
|
||||||
:subs/created-count
|
:subs/created-count
|
||||||
:<- [:subs/all-sub-traces]
|
:<- [:subs/all-sub-traces]
|
||||||
|
@ -340,3 +363,15 @@
|
||||||
:<- [:subs/all-sub-traces]
|
:<- [:subs/all-sub-traces]
|
||||||
(fn [traces]
|
(fn [traces]
|
||||||
(count (filter metam/subscription-not-run? traces))))
|
(count (filter metam/subscription-not-run? traces))))
|
||||||
|
|
||||||
|
(rf/reg-sub
|
||||||
|
:subs/unchanged-l2-subs-count
|
||||||
|
:<- [:subs/all-subs]
|
||||||
|
(fn [subs]
|
||||||
|
(count (filter metam/unchanged-l2-subscription? subs))))
|
||||||
|
|
||||||
|
(rf/reg-sub
|
||||||
|
:subs/ignore-unchanged-subs?
|
||||||
|
:<- [:subs/root]
|
||||||
|
(fn [subs _]
|
||||||
|
(:ignore-unchanged-subs? subs true)))
|
||||||
|
|
|
@ -81,7 +81,9 @@
|
||||||
(let [created-count (rf/subscribe [:subs/created-count])
|
(let [created-count (rf/subscribe [:subs/created-count])
|
||||||
re-run-count (rf/subscribe [:subs/re-run-count])
|
re-run-count (rf/subscribe [:subs/re-run-count])
|
||||||
destroyed-count (rf/subscribe [:subs/destroyed-count])
|
destroyed-count (rf/subscribe [:subs/destroyed-count])
|
||||||
not-run-count (rf/subscribe [:subs/not-run-count])]
|
not-run-count (rf/subscribe [:subs/not-run-count])
|
||||||
|
ignore-unchanged? (rf/subscribe [:subs/ignore-unchanged-subs?])
|
||||||
|
ignore-unchanged-l2-count (rf/subscribe [:subs/unchanged-l2-subs-count])]
|
||||||
[rc/h-box
|
[rc/h-box
|
||||||
:justify :between
|
:justify :between
|
||||||
:align :center
|
:align :center
|
||||||
|
@ -111,10 +113,10 @@
|
||||||
:border "1px solid #e3e9ed"
|
:border "1px solid #e3e9ed"
|
||||||
:border-radius "3px"}
|
:border-radius "3px"}
|
||||||
:children [[rc/checkbox
|
:children [[rc/checkbox
|
||||||
:model true
|
:model ignore-unchanged?
|
||||||
:label [:span "Ignore unchanged" [:br] "layer 2 subs"]
|
:label [:span "Ignore " [:b {:style {:font-weight "700"}} @ignore-unchanged-l2-count] " unchanged" [:br] "layer 2 subs"]
|
||||||
:style {:margin-top "6px"}
|
:style {:margin-top "6px"}
|
||||||
:on-change #()]]]]]))
|
:on-change #(rf/dispatch [:subs/ignore-unchanged-subs? %])]]]]]))
|
||||||
|
|
||||||
(defn pod-header [{:keys [id type layer path open? diff?]}]
|
(defn pod-header [{:keys [id type layer path open? diff?]}]
|
||||||
[rc/h-box
|
[rc/h-box
|
||||||
|
@ -231,7 +233,7 @@
|
||||||
:children [[rc/label :label "There are no subscriptions to show"]]])
|
:children [[rc/label :label "There are no subscriptions to show"]]])
|
||||||
|
|
||||||
(defn pod-section []
|
(defn pod-section []
|
||||||
(let [all-subs @(rf/subscribe [:subs/all-subs])]
|
(let [all-subs @(rf/subscribe [:subs/visible-subs])]
|
||||||
[rc/v-box
|
[rc/v-box
|
||||||
:gap pod-gap
|
:gap pod-gap
|
||||||
:children (if (empty? all-subs)
|
:children (if (empty? all-subs)
|
||||||
|
|
Loading…
Reference in New Issue