Skip to content
Snippets Groups Projects
Commit 633bc899 authored by Cam Saul's avatar Cam Saul
Browse files

Make most sync output 'debug' instead of 'info' - unclutter tests

parent 12284579
No related branches found
No related tags found
No related merge requests found
......@@ -66,7 +66,7 @@
(let [existing-table-names (set (keys table-name->id))
new-table-names (set/difference active-table-names existing-table-names)]
(when (seq new-table-names)
(log/info (u/format-color 'blue "Found new tables: %s" new-table-names))
(log/debug (u/format-color 'blue "Found new tables: %s" new-table-names))
(doseq [new-table-name new-table-names]
(ins Table :db_id (:id database), :active true, :name new-table-name)))))
......@@ -186,7 +186,7 @@
{:pre [(set? pk-fields)
(every? string? pk-fields)]}
(doseq [{field-name :name field-id :id} (sel :many :fields [Field :name :id], :table_id (:id table), :special_type nil, :name [in pk-fields], :parent_id nil)]
(log/info (u/format-color 'green "Field '%s.%s' is a primary key. Marking it as such." (:name table) field-name))
(log/debug (u/format-color 'green "Field '%s.%s' is a primary key. Marking it as such." (:name table) field-name))
(upd Field field-id :special_type :id)))
(defn- sync-table-active-fields-and-pks!
......@@ -212,7 +212,7 @@
(let [existing-field-names (set (keys existing-field-name->field))
new-field-names (set/difference (set (keys active-column-names->type)) existing-field-names)]
(when (seq new-field-names)
(log/info (u/format-color 'blue "Found new fields for table '%s': %s" (:name table) new-field-names)))
(log/debug (u/format-color 'blue "Found new fields for table '%s': %s" (:name table) new-field-names)))
(doseq [[active-field-name active-field-type] active-column-names->type]
;; If Field doesn't exist create it
(if-not (contains? existing-field-names active-field-name)
......@@ -223,7 +223,7 @@
;; Otherwise update the Field type if needed
(let [{existing-base-type :base_type, existing-field-id :id} (existing-field-name->field active-field-name)]
(when-not (= active-field-type existing-base-type)
(log/info (u/format-color 'blue "Field '%s.%s' has changed from a %s to a %s." (:name table) active-field-name existing-base-type active-field-type))
(log/debug (u/format-color 'blue "Field '%s.%s' has changed from a %s to a %s." (:name table) active-field-name existing-base-type active-field-type))
(upd Field existing-field-id :base_type active-field-type))))))
;; TODO - we need to add functionality to update nested Field base types as well!
......@@ -262,7 +262,7 @@
(when-let [fk-column-id (fk-name->id fk-column-name)]
(when-let [dest-table-id (table-name->id dest-table-name)]
(when-let [dest-column-id (sel :one :id Field, :table_id dest-table-id, :name dest-column-name, :parent_id nil)]
(log/info (u/format-color 'green "Marking foreign key '%s.%s' -> '%s.%s'." (:name table) fk-column-name dest-table-name dest-column-name))
(log/debug (u/format-color 'green "Marking foreign key '%s.%s' -> '%s.%s'." (:name table) fk-column-name dest-table-name dest-column-name))
(ins ForeignKey
:origin_id fk-column-id
:destination_id dest-column-id
......@@ -329,7 +329,7 @@
[field]
(when (nil? (:display_name field))
(let [display-name (common/name->human-readable-name (:name field))]
(log/info (u/format-color 'green "Field '%s.%s' has no display_name. Setting it now." (:name @(:table field)) (:name field) display-name))
(log/debug (u/format-color 'green "Field '%s.%s' has no display_name. Setting it now." (:name @(:table field)) (:name field) display-name))
(upd Field (:id field) :display_name display-name)
(assoc field :display_name display-name))))
......@@ -371,7 +371,7 @@
(assert (>= percent-urls 0.0))
(assert (<= percent-urls 100.0))
(when (> percent-urls percent-valid-url-threshold)
(log/info (u/format-color 'green "Field '%s' is %d%% URLs. Marking it as a URL." @(:qualified-name field) (int (math/round (* 100 percent-urls)))))
(log/debug (u/format-color 'green "Field '%s' is %d%% URLs. Marking it as a URL." @(:qualified-name field) (int (math/round (* 100 percent-urls)))))
(upd Field (:id field) :special_type :url)
(assoc field :special_type :url)))))
......@@ -388,7 +388,7 @@
(let [cardinality (queries/field-distinct-count field low-cardinality-threshold)]
(when (and (> cardinality 0)
(< cardinality low-cardinality-threshold))
(log/info (u/format-color 'green "Field '%s' has %d unique values. Marking it as a category." @(:qualified-name field) cardinality))
(log/debug (u/format-color 'green "Field '%s' has %d unique values. Marking it as a category." @(:qualified-name field) cardinality))
(upd Field (:id field) :special_type :category)
(assoc field :special_type :category))))
......@@ -431,7 +431,7 @@
(let [avg-len (field-avg-length driver field)]
(assert (integer? avg-len) "field-avg-length should return an integer.")
(when (> avg-len average-length-no-preview-threshold)
(log/info (u/format-color 'green "Field '%s' has an average length of %d. Not displaying it in previews." @(:qualified-name field) avg-len))
(log/debug (u/format-color 'green "Field '%s' has an average length of %d. Not displaying it in previews." @(:qualified-name field) avg-len))
(upd Field (:id field) :preview_display false)
(assoc field :preview_display false)))))
......@@ -465,7 +465,7 @@
(contains? #{:CharField :TextField} (:base_type field))
(values-are-valid-json? (->> (field-values-lazy-seq driver field)
(take max-sync-lazy-seq-results))))
(log/info (u/format-color 'green "Field '%s' looks like it contains valid JSON objects. Setting special_type to :json." @(:qualified-name field)))
(log/debug (u/format-color 'green "Field '%s' looks like it contains valid JSON objects. Setting special_type to :json." @(:qualified-name field)))
(upd Field (:id field) :special_type :json, :preview_display false)
(assoc field :special_type :json, :preview_display false)))
......@@ -541,7 +541,7 @@
[field]
(when-not (:special_type field)
(when-let [[pattern _ special-type] (field->name-inferred-special-type field)]
(log/info (u/format-color 'green "%s '%s' matches '%s'. Setting special_type to '%s'."
(log/debug (u/format-color 'green "%s '%s' matches '%s'. Setting special_type to '%s'."
(name (:base_type field)) @(:qualified-name field) pattern (name special-type)))
(upd Field (:id field) :special_type special-type)
(assoc field :special_type special-type))))
......@@ -564,7 +564,7 @@
;; OK, now create new Field objects for ones that came back from active-nested-field-name->type but *aren't* in existing-nested-field-name->id
(doseq [[nested-field-name nested-field-type] nested-field-name->type]
(when-not (contains? (set (map keyword (keys existing-nested-field-name->id))) (keyword nested-field-name))
(log/info (u/format-color 'blue "Found new nested field: '%s.%s'" @(:qualified-name field) (name nested-field-name)))
(log/debug (u/format-color 'blue "Found new nested field: '%s.%s'" @(:qualified-name field) (name nested-field-name)))
(let [nested-field (ins Field, :table_id (:table_id field), :parent_id (:id field), :name (name nested-field-name) :base_type (name nested-field-type), :active true)]
;; Now recursively sync this nested Field
;; Replace parent so deref doesn't need to do a DB call
......
......@@ -88,7 +88,6 @@
(or (metabase-instance database-definition engine)
(do
;; Create the database
(log/info (format "Creating %s database %s..." (name engine) database-name))
(create-physical-db! dataset-loader database-definition)
;; Load data
......
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