Skip to content
Snippets Groups Projects
Commit c98e9404 authored by Simon Belak's avatar Simon Belak
Browse files

Merge branch 'master' of github.com:metabase/metabase into xray-sql

parents 86e95899 2f8073b9
Branches
Tags
No related merge requests found
......@@ -196,7 +196,7 @@ You can also skim through [`__support__/integrated_tests.js`](https://github.com
Unit tests are focused around isolated parts of business logic.
Integration tests use an enforced file naming convention `<test-suite-name>.unit.js` to separate them from integration tests.
Unit tests use an enforced file naming convention `<test-suite-name>.unit.js` to separate them from integration tests.
```
yarn run jest-test # Run all tests at once
......
......@@ -53,7 +53,7 @@ How you upgrade Metabase depends on how you are running it. See below for inform
If you are running Metabase via docker, then you simply need to kill the Docker process and start a new container with the latest Metabase image. On startup, Metabase will perform any upgrade tasks it needs to perform, and once it's finished you'll be running the new version.
#### Jar file
If you are running the JVM Jar file directly, then you simply kill the process and restart the server. On startup, Metabase will perform any upgrade tasks it needs to perform, and once it's finished you'll be running the new version.
If you are running the JVM Jar file directly, then you simply kill the process, replace the .jar file with the newer version and restart the server. On startup, Metabase will perform any upgrade tasks it needs to perform, and once it's finished you'll be running the new version.
#### macOS Application
......
......@@ -161,7 +161,10 @@
(def ^:private coordinate-default-index
(dimension-index-for-type "type/Coordinate" #(.contains ^String (:name %) "Auto bin")))
(defn- assoc-field-dimension-options [{:keys [base_type special_type fingerprint] :as field}]
(defn- supports-numeric-binning? [driver]
(and driver (contains? (driver/features driver) :binning)))
(defn- assoc-field-dimension-options [driver {:keys [base_type special_type fingerprint] :as field}]
(let [{min_value :min, max_value :max} (get-in fingerprint [:type :type/Number])
[default-option all-options] (cond
......@@ -170,12 +173,14 @@
[date-default-index datetime-dimension-indexes]
(and min_value max_value
(isa? special_type :type/Coordinate))
(isa? special_type :type/Coordinate)
(supports-numeric-binning? driver))
[coordinate-default-index coordinate-dimension-indexes]
(and min_value max_value
(isa? base_type :type/Number)
(or (nil? special_type) (isa? special_type :type/Number)))
(or (nil? special_type) (isa? special_type :type/Number))
(supports-numeric-binning? driver))
[numeric-default-index numeric-dimension-indexes]
:else
......@@ -185,16 +190,10 @@
:dimension_options all-options)))
(defn- assoc-dimension-options [resp driver]
(if (and driver (contains? (driver/features driver) :binning))
(-> resp
(assoc :dimension_options dimension-options-for-response)
(update :fields #(mapv assoc-field-dimension-options %)))
(-> resp
(assoc :dimension_options [])
(update :fields (fn [fields]
(mapv #(assoc %
:dimension_options []
:default_dimension_option nil) fields))))))
(-> resp
(assoc :dimension_options dimension-options-for-response)
(update :fields (fn [fields]
(mapv #(assoc-field-dimension-options driver %) fields)))))
(defn- format-fields-for-response [resp]
(update resp :fields
......
(ns metabase.util.stats
"Functions which summarize the usage of an instance"
(:require [clj-http.client :as client]
[clojure.string :as str]
[clojure.tools.logging :as log]
[medley.core :as m]
[metabase
......@@ -347,6 +348,25 @@
{:average_entry_size (int (or length 0))
:num_queries_cached (bin-small-number count)}))
;;; System Metrics
(defn- bytes->megabytes [b]
(Math/round (double (/ b 1024 1024))))
(def ^:private system-property-names
["java.version" "java.vm.specification.version" "java.runtime.name"
"user.timezone" "user.language" "user.country" "file.encoding"
"os.name" "os.version"])
(defn- system-metrics
"Metadata about the environment Metabase is running in"
[]
(let [runtime (Runtime/getRuntime)]
(merge
{:max_memory (bytes->megabytes (.maxMemory runtime))
:processors (.availableProcessors runtime)}
(zipmap (map #(keyword (str/replace % \. \_)) system-property-names)
(map #(System/getProperty %) system-property-names)))))
;;; Combined Stats & Logic for sending them in
......@@ -367,6 +387,7 @@
:pulse (pulse-metrics)
:question (question-metrics)
:segment (segment-metrics)
:system (system-metrics)
:table (table-metrics)
:user (user-metrics)}}))
......
......@@ -22,11 +22,15 @@
[util :as tu :refer [match-$]]]
[metabase.test.data
[dataset-definitions :as defs]
[datasets :as datasets]
[users :refer [user->client]]]
[toucan
[db :as db]
[hydrate :as hydrate]]
[toucan.util.test :as tt]))
[toucan.util.test :as tt]
[metabase.query-processor-test :as qpt]
[metabase.timeseries-query-processor-test :as timeseries-qp-test]
[metabase.test.data.datasets :as datasets :refer [*driver* *engine*]]))
;; ## /api/org/* AUTHENTICATION Tests
;; We assume that all endpoints for a given context are enforced by the same middleware, so we don't run the same
......@@ -559,10 +563,11 @@
(db/update! Field lat-field-id :fingerprint fingerprint)))))
(defn- dimension-options-for-field [response field-name]
(->> response
:fields
(m/find-first #(= field-name (:name %)))
:dimension_options))
(let [formatted-field-name (data/format-name field-name)]
(->> response
:fields
(m/find-first #(= formatted-field-name (:name %)))
:dimension_options)))
(defn- extract-dimension-options
"For the given `FIELD-NAME` find it's dimension_options following
......@@ -579,7 +584,7 @@
#{nil "bin-width" "default"}
#{})
(let [response ((user->client :rasta) :get 200 (format "table/%d/query_metadata" (data/id :venues)))]
(extract-dimension-options response "LATITUDE")))
(extract-dimension-options response "latitude")))
;; Number columns without a special type should use "num-bins"
(expect
......@@ -591,7 +596,7 @@
(db/update! Field (data/id :venues :price) :special_type nil)
(let [response ((user->client :rasta) :get 200 (format "table/%d/query_metadata" (data/id :venues)))]
(extract-dimension-options response "PRICE"))
(extract-dimension-options response "price"))
(finally
(db/update! Field (data/id :venues :price) :special_type special_type)))))
......@@ -601,4 +606,16 @@
(var-get #'table-api/datetime-dimension-indexes)
(data/dataset sad-toucan-incidents
(let [response ((user->client :rasta) :get 200 (format "table/%d/query_metadata" (data/id :incidents)))]
(dimension-options-for-field response "TIMESTAMP"))))
(dimension-options-for-field response "timestamp"))))
;; Datetime binning options should showup whether the backend supports binning of numeric values or not
(datasets/expect-with-engines #{:druid}
(var-get #'table-api/datetime-dimension-indexes)
(timeseries-qp-test/with-flattened-dbdef
(let [response ((user->client :rasta) :get 200 (format "table/%d/query_metadata" (data/id :checkins)))]
(dimension-options-for-field response "timestamp"))))
(qpt/expect-with-non-timeseries-dbs
(var-get #'table-api/datetime-dimension-indexes)
(let [response ((user->client :rasta) :get 200 (format "table/%d/query_metadata" (data/id :checkins)))]
(dimension-options-for-field response "date")))
......@@ -67,6 +67,13 @@
(expect false ((anonymous-usage-stats) :sso_configured))
(expect false ((anonymous-usage-stats) :has_sample_data))
;;Spot checking a few system stats to ensure conversion from property
;;names and presence in the anonymous-usage-stats
(expect
#{true}
(let [system-stats (get-in (anonymous-usage-stats) [:stats :system])]
(into #{} (map #(contains? system-stats %) [:java_version :java_runtime_name :max_memory]))))
;;; check that the new lazy-seq version of the executions metrics works the same way the old one did
(tu/resolve-private-vars metabase.util.stats
execution-metrics histogram)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment