Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
4657a4a4
Commit
4657a4a4
authored
7 years ago
by
Simon Belak
Browse files
Options
Downloads
Patches
Plain Diff
Add schemas to api endpoints
parent
5abc1bce
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/metabase/api/automagic_dashboards.clj
+44
-0
44 additions, 0 deletions
src/metabase/api/automagic_dashboards.clj
src/metabase/automagic_dashboards/filters.clj
+1
-1
1 addition, 1 deletion
src/metabase/automagic_dashboards/filters.clj
with
45 additions
and
1 deletion
src/metabase/api/automagic_dashboards.clj
+
44
−
0
View file @
4657a4a4
...
...
@@ -16,14 +16,35 @@
[
query
:refer
[
Query
]
:as
query
]
[
segment
:refer
[
Segment
]]
[
table
:refer
[
Table
]]]
[
metabase.util.schema
:as
su
]
[
ring.util.codec
:as
codec
]
[
schema.core
:as
s
]
[
toucan
[
db
:as
db
]
[
hydrate
:refer
[
hydrate
]]]))
(
def
^
:private
Show
(
s/maybe
(
s/enum
"all"
)))
(
def
^
:private
Rule
s/Str
)
(
def
^
:private
Prefix
(
->>
[
"table"
"metric"
"field"
]
(
mapcat
rules/load-rules
)
(
filter
:indepth
)
(
map
:rule
)
(
apply
s/enum
)))
(
def
^
:private
Rule
(
->>
[
"table"
"metric"
"field"
]
(
mapcat
rules/load-rules
)
(
mapcat
:indepth
)
(
map
:rule
)
(
apply
s/enum
)))
(
def
^
:private
^
{
:arglists
'
([
s
])}
decode-base64-json
(
comp
json/decode
codecs/bytes->str
codec/base64-decode
))
(
def
^
:private
Base64EncodedJSON
(
s/pred
decode-base64-json
))
(
defn-
load-rule
[
entity
prefix
rule
]
(
rules/load-rule
(
format
"%s/%s/%s.yaml"
entity
prefix
rule
)))
...
...
@@ -35,16 +56,21 @@
api/check-404
magic/candidate-tables
))
;; ----------------------------------------- API Endpoints for viewing a transient dashboard ----------------
(
api/defendpoint
GET
"/table/:id"
"Return an automagic dashboard for table with id `ìd`."
[
id
show
]
{
show
Show
}
(
->
id
Table
api/check-404
(
magic/automagic-analysis
{
:show
(
keyword
show
)})))
(
api/defendpoint
GET
"/table/:id/:prefix/:rule"
"Return an automagic dashboard for table with id `ìd` using rule `rule`."
[
id
prefix
rule
show
]
{
show
Show
prefix
Prefix
rule
Rule
}
(
->
id
Table
api/check-404
...
...
@@ -55,11 +81,15 @@
(
api/defendpoint
GET
"/segment/:id"
"Return an automagic dashboard analyzing segment with id `id`."
[
id
show
]
{
show
Show
}
(
->
id
Segment
api/check-404
(
magic/automagic-analysis
{
:show
(
keyword
show
)})))
(
api/defendpoint
GET
"/segment/:id/:prefix/:rule"
"Return an automagic dashboard analyzing segment with id `id`. using rule `rule`."
[
id
prefix
rule
show
]
{
show
Show
prefix
Prefix
rule
Rule
}
(
->
id
Segment
api/check-404
...
...
@@ -71,6 +101,8 @@
"Return an automagic dashboard analyzing cell in question with id `id` defined by
query `cell-querry`."
[
id
cell-query
show
]
{
show
Show
cell-query
Base64EncodedJSON
}
(
->
id
Card
api/check-404
...
...
@@ -81,6 +113,10 @@
"Return an automagic dashboard analyzing cell in question with id `id` defined by
query `cell-querry` using rule `rule`."
[
id
cell-query
prefix
rule
show
]
{
show
Show
prefix
Prefix
rule
Rule
cell-query
Base64EncodedJSON
}
(
->
id
Card
api/check-404
...
...
@@ -91,21 +127,26 @@
(
api/defendpoint
GET
"/metric/:id"
"Return an automagic dashboard analyzing metric with id `id`."
[
id
show
]
{
show
Show
}
(
->
id
Metric
api/check-404
(
magic/automagic-analysis
{
:show
(
keyword
show
)})))
(
api/defendpoint
GET
"/field/:id"
"Return an automagic dashboard analyzing field with id `id`."
[
id
show
]
{
show
Show
}
(
->
id
Field
api/check-404
(
magic/automagic-analysis
{
:show
(
keyword
show
)})))
(
api/defendpoint
GET
"/question/:id"
"Return an automagic dashboard analyzing question with id `id`."
[
id
show
]
{
show
Show
}
(
->
id
Card
api/check-404
(
magic/automagic-analysis
{
:show
(
keyword
show
)})))
(
api/defendpoint
GET
"/adhoc/:query"
"Return an automagic dashboard analyzing ad hoc query."
[
query
show
]
{
show
Show
query
Base64EncodedJSON
}
(
->
query
decode-base64-json
query/adhoc-query
...
...
@@ -114,6 +155,9 @@
(
api/defendpoint
GET
"/adhoc/:query/cell/:cell-query"
"Return an automagic dashboard analyzing ad hoc query."
[
query
cell-query
show
]
{
show
Show
query
Base64EncodedJSON
cell-query
Base64EncodedJSON
}
(
let
[
query
(
decode-base64-json
query
)
cell-query
(
decode-base64-json
cell-query
)]
(
->
query
...
...
This diff is collapsed.
Click to expand it.
src/metabase/automagic_dashboards/filters.clj
+
1
−
1
View file @
4657a4a4
...
...
@@ -145,7 +145,7 @@
[(
->
field
:table_id
Table
:display_name
)
(
:display_name
field
)]
[(
:display_name
field
)])
:field
-
id
(
:id
field
)
:field
_
id
(
:id
field
)
:type
(
filter-type
field
)
:value
rhs
:op
op
}))))))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment