Create separate subs that ignore view namespaces

These are only needed in the Trace panel, so we don't need to pay the
cost elsewhere. This also fixes the bug where ignored view namespaces
were shown when showing all traces in the Trace panel.
This commit is contained in:
Daniel Compton 2018-01-29 01:14:31 +13:00
parent b62ed52847
commit 6465a09d08
4 changed files with 33 additions and 20 deletions

View File

@ -13,12 +13,14 @@ All notable changes to this project will be documented in this file. This change
* The version of Garden that re-frame-trace uses is now bundled as a source dependency so you should no longer get conflicts if you use Garden 2. * The version of Garden that re-frame-trace uses is now bundled as a source dependency so you should no longer get conflicts if you use Garden 2.
* Refactored re-frame-trace trace parsing internals to incrementally parse new traces. * Refactored re-frame-trace trace parsing internals to incrementally parse new traces.
* Clicking on a trace's expanded information now prints the entire trace to the console instead of just the tags. * Clicking on a trace's expanded information now prints the entire trace to the console instead of just the tags.
* Improved efficency of rendering views that do not need to filter out view namespaces.
### Fixed ### Fixed
* External windows not loading * External windows not loading
* All app-db and subscription path expansions are now independent of each other [#134](https://github.com/Day8/re-frame-trace/issues/134). * All app-db and subscription path expansions are now independent of each other [#134](https://github.com/Day8/re-frame-trace/issues/134).
* Layer 2/3 calculations are more accurate now. We now use the last seen layer level when a subscription runs, to inform it's layer level if it was created or destroyed. * Layer 2/3 calculations are more accurate now. We now use the last seen layer level when a subscription runs, to inform it's layer level if it was created or destroyed.
* View namespaces that are ignored are no longer shown when showing traces for all epochs.

View File

@ -514,13 +514,16 @@
subscription-info (->> new-traces subscription-info (->> new-traces
(filter metam/subscription-re-run?) (filter metam/subscription-re-run?)
(reduce (fn [state trace] (reduce (fn [state trace]
;; TODO: can we take any shortcuts by assuming that a sub with ;; Can we take any shortcuts by assuming that a sub with
;; multiple input signals is a layer 3? I don't *think* so because ;; multiple input signals is a layer 3? I don't *think* so because
;; one of those input signals could be a naughty subscription to app-db ;; one of those input signals could be a naughty subscription to app-db
;; directly. ;; directly.
;; If any of the input signals are app-db, it is a layer 2 sub, else 3 ;; If we knew when subscription handlers were loaded/reloaded then
;; we could avoid doing most of this work, and only check the input
;; signals if we hadn't seen it before, or it had been reloaded.
(assoc-in state (assoc-in state
[(:operation trace) :layer] [(:operation trace) :layer]
;; If any of the input signals are app-db, it is a layer 2 sub, else 3
(if (some #(= app-db-id %) (get-in trace [:tags :input-signals])) (if (some #(= app-db-id %) (get-in trace [:tags :input-signals]))
2 2
3))) 3)))

View File

@ -145,29 +145,37 @@
(fn [traces _] (fn [traces _]
(count traces))) (count traces)))
(rf/reg-sub
:traces/all-visible-traces
:<- [:traces/all-traces]
:<- [:settings/filtered-view-trace]
(fn [[all-traces filtered-views] _]
(let [munged-ns (->> filtered-views
(map (comp munge :ns-str))
(set))]
(into []
;; Filter out view namespaces we don't care about.
(remove
(fn [trace] (and (metam/render? trace)
(contains? munged-ns (subs (:operation trace) 0 (str/last-index-of (:operation trace) "."))))))
all-traces))))
(rf/reg-sub (rf/reg-sub
:traces/current-event-traces :traces/current-event-traces
:<- [:traces/all-visible-traces] :<- [:traces/all-traces]
:<- [:epochs/beginning-trace-id] :<- [:epochs/beginning-trace-id]
:<- [:epochs/ending-trace-id] :<- [:epochs/ending-trace-id]
(fn [[traces beginning ending] _] (fn [[traces beginning ending] _]
(into [] (filter #(<= beginning (:id %) ending)) traces))) (into [] (filter #(<= beginning (:id %) ending)) traces)))
(defn filter-ignored-views [[traces filtered-views] _]
(let [munged-ns (->> filtered-views
(map (comp munge :ns-str))
(set))]
(into []
;; Filter out view namespaces we don't care about.
(remove
(fn [trace] (and (metam/render? trace)
(contains? munged-ns (subs (:operation trace) 0 (str/last-index-of (:operation trace) "."))))))
traces)))
(rf/reg-sub
:traces/current-event-visible-traces
:<- [:traces/current-event-traces]
:<- [:settings/filtered-view-trace]
filter-ignored-views)
(rf/reg-sub
:traces/all-visible-traces
:<- [:traces/all-traces]
:<- [:settings/filtered-view-trace]
filter-ignored-views)
(rf/reg-sub (rf/reg-sub
:traces/show-epoch-traces? :traces/show-epoch-traces?
:<- [:traces/trace-root] :<- [:traces/trace-root]

View File

@ -89,8 +89,8 @@
trace-detail-expansions (rf/subscribe [:traces/expansions]) trace-detail-expansions (rf/subscribe [:traces/expansions])
beginning (rf/subscribe [:epochs/beginning-trace-id]) beginning (rf/subscribe [:epochs/beginning-trace-id])
end (rf/subscribe [:epochs/ending-trace-id]) end (rf/subscribe [:epochs/ending-trace-id])
traces (rf/subscribe [:traces/all-traces]) traces (rf/subscribe [:traces/all-visible-traces])
current-traces (rf/subscribe [:traces/current-event-traces]) current-traces (rf/subscribe [:traces/current-event-visible-traces])
show-epoch-traces? (rf/subscribe [:traces/show-epoch-traces?])] show-epoch-traces? (rf/subscribe [:traces/show-epoch-traces?])]
(fn [] (fn []
(let [toggle-category-fn #(rf/dispatch [:traces/toggle-categories %]) (let [toggle-category-fn #(rf/dispatch [:traces/toggle-categories %])