Skip to content
Snippets Groups Projects
Commit 9d1ad55c authored by Paul Rosenzweig's avatar Paul Rosenzweig Committed by Cam Saul
Browse files

Fix trend widget for years (#10722)

* fix issue preventing insights on year-grouped data

* remove (probably) unnecessary function

* formatting/style

* years are timestamps now
parent e5e5f589
No related branches found
No related tags found
No related merge requests found
......@@ -206,16 +206,6 @@
:col (:name number-col)
:unit unit})))))))
(defn- datetime-truncated-to-year?
"This is hackish as hell, but we change datetimes with year granularity to strings upstream and
this is the only way to recover the information they were once datetimes."
[{:keys [base_type unit fingerprint] :as field}]
(and (= base_type :type/Text)
(contains? field :unit)
(nil? unit)
(or (nil? (:type fingerprint))
(-> fingerprint :type :type/DateTime))))
(defn insights
"Based on the shape of returned data construct a transducer to statistically analyize data."
[cols]
......@@ -225,7 +215,7 @@
(group-by (fn [{:keys [base_type special_type unit] :as field}]
(cond
(#{:type/FK :type/PK} special_type) :others
(datetime-truncated-to-year? field) :datetimes
(= unit :year) :datetimes
(metabase.util.date/date-extract-units unit) :numbers
(field/unix-timestamp? field) :datetimes
(isa? base_type :type/Number) :numbers
......
......@@ -34,6 +34,12 @@
first
:last-value))
(expect
(transduce identity
(insights [{:base_type :type/DateTime :unit :year}
{:base_type :type/Integer}])
[["2014-01-01T00:00:00Z" 100]
["2015-01-01T00:00:00Z" 200]]))
(defn- inst->day
[inst]
......
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