Skip to content
Snippets Groups Projects
Unverified Commit 8f23be70 authored by Cal Herries's avatar Cal Herries Committed by GitHub
Browse files

Refactor: separate param-values from API endpoint usage (#35001)

parent 015327d0
No related branches found
No related tags found
No related merge requests found
......@@ -862,8 +862,8 @@
- static-list: user defined values list
- card: values is result of running a card
- nil: chain-filter"
([dashboard param-key query-params]
(param-values dashboard param-key query-params nil))
([dashboard param-key constraint-param-key->value]
(param-values dashboard param-key constraint-param-key->value nil))
([dashboard :- :map
param-key :- ms/NonBlankString
......@@ -883,12 +883,12 @@
;; fetch values for Dashboard 1 parameter 'abc' that are possible when parameter 'def' is set to 100
GET /api/dashboard/1/params/abc/values?def=100"
[id param-key :as {:keys [query-params]}]
[id param-key :as {constraint-param-key->value :query-params}]
{id ms/PositiveInt}
(let [dashboard (api/read-check :model/Dashboard id)]
;; If a user can read the dashboard, then they can lookup filters. This also works with sandboxing.
(binding [qp.perms/*param-values-query* true]
(param-values dashboard param-key query-params))))
(param-values dashboard param-key constraint-param-key->value))))
(api/defendpoint GET "/:id/params/:param-key/search/:query"
"Fetch possible values of the parameter whose ID is `:param-key` that contain `:query`. Optionally restrict
......@@ -899,13 +899,13 @@
GET /api/dashboard/1/params/abc/search/Cam?def=100
Currently limited to first 1000 results."
[id param-key query :as {:keys [query-params]}]
[id param-key query :as {constraint-param-key->value :query-params}]
{id ms/PositiveInt
query ms/NonBlankString}
(let [dashboard (api/read-check :model/Dashboard id)]
;; If a user can read the dashboard, then they can lookup filters. This also works with sandboxing.
(binding [qp.perms/*param-values-query* true]
(param-values dashboard param-key query-params query))))
(param-values dashboard param-key constraint-param-key->value query))))
(api/defendpoint GET "/params/valid-filter-fields"
"Utility endpoint for powering Dashboard UI. Given some set of `filtered` Field IDs (presumably Fields used in
......
......@@ -575,22 +575,22 @@
(api/defendpoint GET "/dashboard/:uuid/params/:param-key/values"
"Fetch filter values for dashboard parameter `param-key`."
[uuid param-key :as {:keys [query-params]}]
[uuid param-key :as {constraint-param-key->value :query-params}]
{uuid ms/UUIDString
param-key ms/NonBlankString}
(let [dashboard (dashboard-with-uuid uuid)]
(mw.session/as-admin
(api.dashboard/param-values dashboard param-key query-params))))
(api.dashboard/param-values dashboard param-key constraint-param-key->value))))
(api/defendpoint GET "/dashboard/:uuid/params/:param-key/search/:query"
"Fetch filter values for dashboard parameter `param-key`, containing specified `query`."
[uuid param-key query :as {:keys [query-params]}]
[uuid param-key query :as {constraint-param-key->value :query-params}]
{uuid ms/UUIDString
param-key ms/NonBlankString
query ms/NonBlankString}
(let [dashboard (dashboard-with-uuid uuid)]
(mw.session/as-admin
(api.dashboard/param-values dashboard param-key query-params query))))
(api.dashboard/param-values dashboard param-key constraint-param-key->value query))))
;;; ----------------------------------------------------- Pivot Tables -----------------------------------------------
......
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