Skip to content
Snippets Groups Projects
Commit 1cec7321 authored by Cam Saül's avatar Cam Saül
Browse files

Return average_execution_time with query executions

parent 9f56f825
No related branches found
No related tags found
No related merge requests found
......@@ -92,10 +92,10 @@
[session-id]
(when (and session-id (init-status/complete?))
(when-let [session (or (session-with-id session-id)
(println "no matching session with ID") ; NOCOMMIT
(println "no matching session with ID") ; DEBUG
)]
(if (session-expired? session)
(println (format "session-is-expired! %d min / %d min" (session-age-minutes session) (config/config-int :max-session-age))) ; NOCOMMIT
(println (format "session-is-expired! %d min / %d min" (session-age-minutes session) (config/config-int :max-session-age))) ; DEBUG
{:metabase-user-id (:user_id session)
:is-superuser? (:is_superuser session)}))))
......
......@@ -142,7 +142,9 @@
(-> query-execution
(dissoc :error :result_rows :hash :executor_id :native :card_id :dashboard_id :pulse_id)
(merge query-result)
(assoc :status :completed))))
(assoc :status :completed
:average_execution_time (when (:cached query-result)
(query/average-execution-time-ms (:hash query-execution)))))))
(defn- assert-query-status-successful
......
......@@ -40,7 +40,7 @@
(defn format-response [m]
(into {} (for [[k v] m]
(cond
(contains? #{:id :started_at :running_time :hash} k) [k (boolean v)]
(contains? #{:id :started_at :running_time :hash :average_execution_time} k) [k (boolean v)]
(= :data k) [k (if-not (contains? v :native_form)
v
(update v :native_form boolean))]
......@@ -52,22 +52,23 @@
;; Just a basic sanity check to make sure Query Processor endpoint is still working correctly.
(expect
[;; API call response
{:data {:rows [[1000]]
:columns ["count"]
:cols [{:base_type "type/Integer", :special_type "type/Number", :name "count", :display_name "count", :id nil, :table_id nil,
:description nil, :target nil, :extra_info {}, :source "aggregation"}]
:native_form true}
:row_count 1
:status "completed"
:context "ad-hoc"
:json_query (-> (wrap-inner-query
(query checkins
(ql/aggregation (ql/count))))
(assoc :type "query")
(assoc-in [:query :aggregation] [{:aggregation-type "count", :custom-name nil}])
(assoc :constraints default-query-constraints))
:started_at true
:running_time true}
{:data {:rows [[1000]]
:columns ["count"]
:cols [{:base_type "type/Integer", :special_type "type/Number", :name "count", :display_name "count", :id nil, :table_id nil,
:description nil, :target nil, :extra_info {}, :source "aggregation"}]
:native_form true}
:row_count 1
:status "completed"
:context "ad-hoc"
:json_query (-> (wrap-inner-query
(query checkins
(ql/aggregation (ql/count))))
(assoc :type "query")
(assoc-in [:query :aggregation] [{:aggregation-type "count", :custom-name nil}])
(assoc :constraints default-query-constraints))
:started_at true
:running_time true
:average_execution_time true}
;; QueryExecution record in the DB
{:hash true
:row_count 1
......
......@@ -19,7 +19,7 @@
(defn- api-call-was-successful? {:style/indent 0} [response]
(when (and (string? response)
(not= response "You don't have permissions to do that."))
(println "users in db:" (db/select-field :email 'User)) ; NOCOMMIT
(println "users in db:" (db/select-field :email 'User)) ; DEBUG
(println "RESPONSE:" response)) ; DEBUG
(not= response "You don't have permissions to do that."))
......
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