Skip to content
Snippets Groups Projects
Unverified Commit be3b4015 authored by Kyle Doherty's avatar Kyle Doherty
Browse files

Merge branch 'fingerprints-poc' of github.com:metabase/metabase into fingerprints-poc

parents 09213c0c 4f8dcb67
No related branches found
No related tags found
No related merge requests found
......@@ -33,7 +33,7 @@
{:query (keyword query)
:computation (keyword computation)})
(api/defendpoint GET "/field/:id/:max_query_cost/:max_computation_cost"
(api/defendpoint GET "/field/:id"
"Get fingerprint for a `Field` with ID."
[id max_query_cost max_computation_cost]
{max_query_cost MaxQueryCost
......
......@@ -56,14 +56,16 @@
(defmethod fingerprint (type Field)
[opts field]
{:fingerprint (->> (metadata/field-values field (extract-query-opts opts))
(fingerprint-field opts field))})
(fingerprint-field opts field)
(merge {:table (Table (:table_id field))}))})
(defmethod fingerprint (type Table)
[opts table]
{:constituents (fingerprint-query opts (metadata/query-values
(:db_id table)
(merge (extract-query-opts opts)
{:source-table (:id table)})))})
{:source-table (:id table)})))
:fingerprint {:table table}})
(defmethod fingerprint (type Card)
[opts card]
......@@ -75,14 +77,18 @@
fields [(first breakout) (or (first aggregation) (second breakout))]]
{:constituents [(fingerprint-field opts (first fields) (map first rows))
(fingerprint-field opts (second fields) (map second rows))]
:fingerprint (fingerprint-field opts fields rows)}))
:fingerprint (merge (fingerprint-field opts fields rows)
{:card card
:table (Table (:table_id card))})}))
(defmethod fingerprint (type Segment)
[opts segment]
{:constituents (fingerprint-query opts (metadata/query-values
(metadata/db-id segment)
(merge (extract-query-opts opts)
(:definition segment))))})
(:definition segment))))
:fingerprint {:table (Table (:table_id segment))
:segment segment}})
(defmethod fingerprint (type Metric)
[_ metric]
......@@ -138,5 +144,5 @@
"Walk the fingerprint structure and prettify all fingerprints within."
[fingerprint]
(-> fingerprint
(update :fingerprint f/prettify)
(update :constituents (partial map prettify))))
(update :fingerprint f/prettify)
(update :constituents (partial map f/prettify))))
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