Replace time filter when adding a new one

This commit is contained in:
Saskia Lindner 2017-08-31 14:42:44 +02:00 committed by Daniel Compton
parent 562a8c7322
commit 8e3279c39c
1 changed files with 13 additions and 5 deletions

View File

@ -147,12 +147,20 @@
(< (:query query) (:duration trace))))) (< (:query query) (:duration trace)))))
(defn add-filter [filter-items filter-input filter-type] (defn add-filter [filter-items filter-input filter-type]
;; prevent duplicate filter strings
(if-not (some #(= filter-input (:query %)) @filter-items) (if-not (some #(= filter-input (:query %)) @filter-items)
(swap! filter-items conj {:id (random-uuid) (do
:query (if (= filter-type :contains) ;; if existing, remove prior filter for :slower-than
(str/lower-case filter-input) (when (and (= :slower-than filter-type)
(js/parseFloat filter-input)) (some #(= filter-type (:filter-type %)) @filter-items))
:filter-type filter-type}))) (swap! filter-items (fn [item]
(remove #(= :slower-than (:filter-type %)) item))))
;; add new filter
(swap! filter-items conj {:id (random-uuid)
:query (if (= filter-type :contains)
(str/lower-case filter-input)
(js/parseFloat filter-input))
:filter-type filter-type}))))
(defn render-traces [showing-traces filter-items filter-input trace-detail-expansions] (defn render-traces [showing-traces filter-items filter-input trace-detail-expansions]
(doall (doall