mirror of
https://github.com/status-im/re-frame-10x.git
synced 2025-01-13 15:44:24 +00:00
Add setting to control how many epochs are retained
This commit is contained in:
parent
05c9f84225
commit
db14e69f17
@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file. This change
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
* Setting to control how many epochs are retained
|
||||||
|
* Setting to reset all epochs
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
* Updated bundled re-frame version to 0.10.3, and bundled reagent version to 0.7.0. This shouldn't impact your project's dependencies as they are source bundled via [mranderson](https://github.com/benedekfazekas/mranderson).
|
* Updated bundled re-frame version to 0.10.3, and bundled reagent version to 0.7.0. This shouldn't impact your project's dependencies as they are source bundled via [mranderson](https://github.com/benedekfazekas/mranderson).
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
json-ml-paths (localstorage/get "app-db-json-ml-expansions" #{})
|
json-ml-paths (localstorage/get "app-db-json-ml-expansions" #{})
|
||||||
external-window? (localstorage/get "external-window?" false)
|
external-window? (localstorage/get "external-window?" false)
|
||||||
using-trace? (localstorage/get "using-trace?" true)
|
using-trace? (localstorage/get "using-trace?" true)
|
||||||
num-epochs (localstorage/get "retained-epochs" 30)
|
num-epochs (localstorage/get "retained-epochs" 5)
|
||||||
categories (localstorage/get "categories" #{:event :sub/run :sub/create :sub/dispose})]
|
categories (localstorage/get "categories" #{:event :sub/run :sub/create :sub/dispose})]
|
||||||
(when using-trace?
|
(when using-trace?
|
||||||
(rf/dispatch [:global/enable-tracing]))
|
(rf/dispatch [:global/enable-tracing]))
|
||||||
|
@ -14,8 +14,11 @@
|
|||||||
[day8.re-frame.trace.metamorphic :as metam]
|
[day8.re-frame.trace.metamorphic :as metam]
|
||||||
[re-frame.trace]))
|
[re-frame.trace]))
|
||||||
|
|
||||||
|
(def default-number-of-epochs-to-retain 5)
|
||||||
|
|
||||||
(defonce traces (r/atom []))
|
(defonce traces (r/atom []))
|
||||||
(defonce total-traces (r/atom 0))
|
(defonce total-traces (r/atom 0))
|
||||||
|
(defonce number-of-epochs-to-retain (atom default-number-of-epochs-to-retain))
|
||||||
|
|
||||||
(defn log-trace? [trace]
|
(defn log-trace? [trace]
|
||||||
(let [render-operation? (or (= (:op-type trace) :render)
|
(let [render-operation? (or (= (:op-type trace) :render)
|
||||||
@ -43,8 +46,16 @@
|
|||||||
(do (reset! total-traces 0)
|
(do (reset! total-traces 0)
|
||||||
(into [] new2))))
|
(into [] new2))))
|
||||||
new))))
|
new))))
|
||||||
(rf/dispatch [:traces/update-traces @traces])
|
;; TODO: there is a bit of double handling here, that will be cleaned up
|
||||||
(rf/dispatch [:epochs/update-epochs (metam/parse-traces @traces)])))))
|
;; when the epoch parsing is refactored.
|
||||||
|
(let [epochs (metam/parse-traces @traces)
|
||||||
|
retained-epochs (take-last @number-of-epochs-to-retain (:matches epochs))
|
||||||
|
first-id-to-retain (:id (ffirst retained-epochs))
|
||||||
|
new-traces (into [] (drop-while #(< (:id %) first-id-to-retain)) @traces)]
|
||||||
|
(reset! traces new-traces)
|
||||||
|
(reset! total-traces (count new-traces))
|
||||||
|
(rf/dispatch [:traces/update-traces new-traces])
|
||||||
|
(rf/dispatch [:epochs/update-epochs {:matches retained-epochs}]))))))
|
||||||
|
|
||||||
(defn dissoc-in
|
(defn dissoc-in
|
||||||
"Dissociates an entry from a nested associative structure returning a new
|
"Dissociates an entry from a nested associative structure returning a new
|
||||||
@ -133,10 +144,13 @@
|
|||||||
;; TODO: this is not perfect, there is an issue in re-com
|
;; TODO: this is not perfect, there is an issue in re-com
|
||||||
;; where it won't update its model if it never receives another
|
;; where it won't update its model if it never receives another
|
||||||
;; changes after it's on-change is fired.
|
;; changes after it's on-change is fired.
|
||||||
|
;; TODO: you could reset the stored epochs on change here
|
||||||
|
;; once the way they are processed is refactored.
|
||||||
(let [num (js/parseInt num-str)
|
(let [num (js/parseInt num-str)
|
||||||
num (if (and (not (js/isNaN num)) (pos-int? num))
|
num (if (and (not (js/isNaN num)) (pos-int? num))
|
||||||
num
|
num
|
||||||
30)]
|
default-number-of-epochs-to-retain)]
|
||||||
|
(reset! number-of-epochs-to-retain num)
|
||||||
(localstorage/save! "retained-epochs" num)
|
(localstorage/save! "retained-epochs" num)
|
||||||
(assoc-in db [:settings :number-of-epochs] num))))
|
(assoc-in db [:settings :number-of-epochs] num))))
|
||||||
|
|
||||||
@ -478,12 +492,11 @@
|
|||||||
|
|
||||||
(rf/reg-event-db
|
(rf/reg-event-db
|
||||||
:epochs/reset
|
:epochs/reset
|
||||||
[(rf/path [:epochs])]
|
(fn [db]
|
||||||
(fn [epochs]
|
|
||||||
(re-frame.trace/reset-tracing!)
|
(re-frame.trace/reset-tracing!)
|
||||||
(reset! traces [])
|
(reset! traces [])
|
||||||
(reset! total-traces 0)
|
(reset! total-traces 0)
|
||||||
nil))
|
(dissoc db :epochs :traces)))
|
||||||
|
|
||||||
(rf/reg-event-db
|
(rf/reg-event-db
|
||||||
:traces/update-traces
|
:traces/update-traces
|
||||||
|
@ -97,8 +97,7 @@
|
|||||||
num-traces @(rf/subscribe [:traces/number-of-traces])
|
num-traces @(rf/subscribe [:traces/number-of-traces])
|
||||||
epochs-to-retain (rf/subscribe [:settings/number-of-retained-epochs])]
|
epochs-to-retain (rf/subscribe [:settings/number-of-retained-epochs])]
|
||||||
|
|
||||||
;; TODO: retain last
|
[settings-box
|
||||||
#_[settings-box
|
|
||||||
[[rc/h-box
|
[[rc/h-box
|
||||||
:align :center
|
:align :center
|
||||||
:gap horizontal-gap
|
:gap horizontal-gap
|
||||||
@ -118,7 +117,7 @@
|
|||||||
:label [rc/v-box
|
:label [rc/v-box
|
||||||
:align :center
|
:align :center
|
||||||
:children ["clear all epochs"]]
|
:children ["clear all epochs"]]
|
||||||
:on-click #(println "Clicked CLEAR")]]]]
|
:on-click #(rf/dispatch [:epochs/reset])]]]]
|
||||||
[[:p num-epochs " epochs currently retained, involving " num-traces " traces."]]
|
[[:p num-epochs " epochs currently retained, involving " num-traces " traces."]]
|
||||||
settings-box-81])
|
settings-box-81])
|
||||||
|
|
||||||
@ -194,7 +193,7 @@
|
|||||||
[[:p "Most of the time, low level trace is noisy and you want it filtered out."]]
|
[[:p "Most of the time, low level trace is noisy and you want it filtered out."]]
|
||||||
settings-box-131])
|
settings-box-131])
|
||||||
|
|
||||||
#_[rc/line]
|
[rc/line]
|
||||||
[settings-box
|
[settings-box
|
||||||
[[rc/button
|
[[rc/button
|
||||||
:class "bm-muted-button app-db-panel-button"
|
:class "bm-muted-button app-db-panel-button"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user