Skip to content
Snippets Groups Projects
Commit 947a20bb authored by Allen Gilliland's avatar Allen Gilliland
Browse files

* don't put trailing slashes on our api endpoints

* put in defendpoint docstrings as much as possible
parent bcecc828
No related branches found
No related tags found
No related merge requests found
......@@ -126,7 +126,7 @@
<div ng-show="canvas_focus == 'data'">
<div class="clearfix py1">
<div class="float-right">
<a class="Button" ng-href="/api/meta/dataset/csv/?query={{getEncodedQuery(card.dataset_query)}}" target="_self" ng-if="cardData">Download Data</a>
<a class="Button" ng-href="/api/meta/dataset/csv?query={{getEncodedQuery(card.dataset_query)}}" target="_self" ng-if="cardData">Download Data</a>
</div>
<h3>Results</h3>
</div>
......
......@@ -6,13 +6,15 @@
[metabase.driver :as driver]
[metabase.util :as u]))
(defendpoint POST "/" [:as {:keys [body]}]
(defendpoint POST "/"
"Execute an MQL query and retrieve the results as JSON."
[:as {:keys [body]}]
(let [{:keys [status] :as response} (driver/dataset-query body {:executed_by *current-user-id*})]
{:status (if (= status :completed) 200 400)
:body response}))
(defendpoint GET "/csv/"
"Execute an MQL query and download the results as a CSV file."
(defendpoint GET "/csv"
"Execute an MQL query and download the result data as a CSV file."
[query]
{query [Required String->Dict]}
(let [{{:keys [columns rows]} :data :keys [status] :as response} (driver/dataset-query query {:executed_by *current-user-id*})]
......
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