Skip to content
Snippets Groups Projects
Unverified Commit 090d162e authored by Cam Saul's avatar Cam Saul
Browse files

process-query-and-save-with-max! -> process-query-and-save-with-max-results-constraints!

parent 6d6329b7
No related merge requests found
......@@ -47,7 +47,7 @@
(let [source-card-id (query->source-card-id query)
options {:executed-by api/*current-user-id*, :context :ad-hoc,
:card-id source-card-id, :nested? (boolean source-card-id)}]
(qp.async/process-query-and-save-with-max! query options)))
(qp.async/process-query-and-save-with-max-results-constraints! query options)))
;;; ----------------------------------- Downloading Query Results in Other Formats -----------------------------------
......
......@@ -656,7 +656,7 @@
:question
:xlsx-download))
;; TODO - this schema is somewhat misleading because if you use a function like `qp/process-query-and-save-with-max!`
;; TODO - this schema is somewhat misleading because if you use a function like `qp/process-query-and-save-with-max-results-constraints!`
;; some of these keys (e.g. `:context`) are in fact required
(def Info
"Schema for query `:info` dictionary, which is used for informational purposes to record information about how a query
......
......@@ -33,10 +33,11 @@
(when-let [card (Card :id card-id, :archived false)]
(let [{:keys [creator_id dataset_query]} card]
{:card card
:result (qp/process-query-and-save-with-max! dataset_query (merge {:executed-by creator_id,
:context :pulse,
:card-id card-id}
options))}))
:result (qp/process-query-and-save-with-max-results-constraints! dataset_query
(merge {:executed-by creator_id,
:context :pulse,
:card-id card-id}
options))}))
(catch Throwable t
(log/warn t (trs "Error running query for Card {0}" card-id)))))
......
......@@ -395,7 +395,7 @@
{:max-results-bare-rows max-results})
m))
(s/defn process-query-and-save-with-max!
(s/defn process-query-and-save-with-max-results-constraints!
"Same as `process-query-and-save-execution!` but will include the default max rows returned as a constraint. (This
function is ulitmately what powers most API endpoints that run queries, including `POST /api/dataset`.)"
{:style/indent 1}
......
......@@ -70,12 +70,12 @@
[query options]
(do-async (:database query) qp/process-query-and-save-execution! query options))
(defn process-query-and-save-with-max!
"Async version of `metabase.query-processor/process-query-and-save-with-max!`. Runs query asynchronously, and returns
a `core.async` channel that can be used to fetch the results once the query finishes running. Closing the channel
will cancel the query."
(defn process-query-and-save-with-max-results-constraints!
"Async version of `metabase.query-processor/process-query-and-save-with-max-results-constraints!`. Runs query
asynchronously, and returns a `core.async` channel that can be used to fetch the results once the query finishes
running. Closing the channel will cancel the query."
[query options]
(do-async (:database query) qp/process-query-and-save-with-max! query options))
(do-async (:database query) qp/process-query-and-save-with-max-results-constraints! query options))
(defn process-query-without-save!
"Async version of `metabase.query-processor/process-query-without-save!`. Runs query asynchronously, and returns a
......
......@@ -29,8 +29,8 @@
:native (native-query)
:constraints {:max-results 5}})))
;; does it also work when running via `process-query-and-save-with-max!`, the function that powers endpoints like
;; `POST /api/dataset`?
;; does it also work when running via `process-query-and-save-with-max-results-constraints!`, the function that powers
;; endpoints like `POST /api/dataset`?
(qp.test/expect-with-non-timeseries-dbs
[["Red Medicine"]
["Stout Burgers & Beers"]
......@@ -38,7 +38,7 @@
["Wurstküche"]
["Brite Spot Family Restaurant"]]
(qp.test/rows
(qp/process-query-and-save-with-max!
(qp/process-query-and-save-with-max-results-constraints!
{:database (data/id)
:type :native
:native (native-query)
......
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