Skip to content
Snippets Groups Projects
Unverified Commit f0f14798 authored by Howon Lee's avatar Howon Lee Committed by GitHub
Browse files

Trend visualization fix for trivial trend (#19635)

Trivial trends previously broke. Now they default to basically the ordinary single value viz.
parent e64d3192
No related branches found
No related tags found
No related merge requests found
......@@ -654,7 +654,7 @@
:render/text (str value)}))
(s/defmethod render :smartscalar :- common/RenderedPulseCard
[_ _ timezone-id _card _ {:keys [cols _rows insights viz-settings]}]
[_ _ timezone-id _card _ {:keys [cols rows insights viz-settings] :as data}]
(letfn [(col-of-type [t c] (or (isa? (:effective_type c) t)
;; computed and agg columns don't have an effective type
(isa? (:base_type c) t)))
......@@ -684,7 +684,17 @@
:render/text (str value "\n"
adj " " (percentage last-change) "."
" Was " previous " last " (format-unit unit))})
@error-rendered-info))))
;; In other words, defaults to plain scalar if we don't have actual changes
{:attachments nil
:content [:div
[:div {:style (style/style (style/scalar-style))}
(h last-value)]
[:p {:style (style/style {:color style/color-text-medium
:font-size :16px
:font-weight 700
:padding-right :16px})}
(trs "Nothing to compare to.")]]
:render/text (str last-value "\n" (trs "Nothing to compare to."))}))))
(s/defmethod render :sparkline :- common/RenderedPulseCard
[_ render-type timezone-id card _ {:keys [_rows cols viz-settings] :as data}]
......
......@@ -314,9 +314,25 @@
:unit :month
:last-change 1.333333
:col "value"
:last-value 40.0}]}]
:last-value 40.0}]}
;; by "dumb" it is meant "without nonnil insights"
dumbres {:cols [{:name "value",
:display_name "VALUE",
:base_type :type/Decimal}
{:name "time",
:display_name "TIME",
:base_type :type/DateTime
:effective_type :type/DateTime}]
:rows [[20.0 :month-before]]
:insights [{:previous-value nil
:unit nil
:last-change nil
:col "value"
:last-value 20.0}]}]
(is (= "40.00\nUp 133.33%. Was 30.00 last month"
(:render/text (body/render :smartscalar nil pacific-tz nil nil results))))
(is (= "20.0\nNothing to compare to."
(:render/text (body/render :smartscalar nil pacific-tz nil nil dumbres))))
(is (schema= {:attachments (s/eq nil)
:content (s/pred vector? "hiccup vector")
:render/text (s/eq "40.00\nUp 133.33%. Was 30.00 last month")}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment