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
e2462b00
Commit
e2462b00
authored
6 years ago
by
Simon Belak
Browse files
Options
Downloads
Patches
Plain Diff
Correctly handle nested `[field-id]` expressions
parent
d5fb26ac
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/metabase/automagic_dashboards/core.clj
+15
-16
15 additions, 16 deletions
src/metabase/automagic_dashboards/core.clj
with
15 additions
and
16 deletions
src/metabase/automagic_dashboards/core.clj
+
15
−
16
View file @
e2462b00
...
...
@@ -52,17 +52,20 @@
(
defn
->field
"Return `Field` instance for a given ID or name in the context of root."
[
root
id-or-name
]
(
if
(
->>
root
:source
(
instance?
(
type
Table
)))
(
Field
id-or-name
)
(
when-let
[
field
(
->>
root
:source
:result_metadata
(
m/find-first
(
comp
#
{
id-or-name
}
:name
)))]
(
->
field
(
update
:base_type
keyword
)
(
update
:special_type
keyword
)
field/map->FieldInstance
(
classify/run-classifiers
{})))))
(
let
[
id-or-name
(
if
(
sequential?
id-or-name
)
(
filters/field-reference->id
id-or-name
)
id-or-name
)]
(
if
(
->>
root
:source
(
instance?
(
type
Table
)))
(
Field
id-or-name
)
(
when-let
[
field
(
->>
root
:source
:result_metadata
(
m/find-first
(
comp
#
{
id-or-name
}
:name
)))]
(
->
field
(
update
:base_type
keyword
)
(
update
:special_type
keyword
)
field/map->FieldInstance
(
classify/run-classifiers
{}))))))
(
def
^
{
:arglists
'
([
root
])}
source-name
"Return the (display) name of the soruce of a given root object."
...
...
@@ -120,7 +123,6 @@
(
if
(
adhoc-metric?
metric
)
(
tru
"{0} of {1}"
(
metric-name
metric
)
(
or
(
some->>
metric
second
filters/field-reference->id
(
->field
root
)
:display_name
)
(
source-name
root
)))
...
...
@@ -133,8 +135,7 @@
dimensions
(
->>
(
get-in
question
[
:dataset_query
:query
:breakout
])
(
mapcat
filters/collect-field-references
)
(
map
(
comp
:display_name
(
partial
->field
root
)
filters/field-reference->id
))
(
partial
->field
root
)))
join-enumeration
)]
(
if
dimensions
(
tru
"{0} by {1}"
aggregations
dimensions
)
...
...
@@ -1039,7 +1040,6 @@
(
defn-
collect-breakout-fields
[
root
question
]
(
map
(
comp
(
partial
->field
root
)
filters/field-reference->id
first
filters/collect-field-references
)
(
get-in
question
[
:dataset_query
:query
:breakout
])))
...
...
@@ -1095,7 +1095,6 @@
(
cond->
(
->>
field-reference
filters/collect-field-references
first
filters/field-reference->id
(
->field
root
))
(
->
field-reference
first
qp.util/normalize-token
(
=
:datetime-field
))
(
assoc
:unit
(
->
field-reference
last
qp.util/normalize-token
))))
...
...
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