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
b3f4d08f
Commit
b3f4d08f
authored
8 years ago
by
Tom Robinson
Committed by
GitHub
8 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #4092 from metabase/fix-named-aggregations
Fix named aggregation formatting / saving.
parents
64395b75
84041ec1
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/src/metabase/lib/query.js
+8
-4
8 additions, 4 deletions
frontend/src/metabase/lib/query.js
frontend/test/unit/lib/query.spec.js
+20
-0
20 additions, 0 deletions
frontend/test/unit/lib/query.spec.js
with
28 additions
and
4 deletions
frontend/src/metabase/lib/query.js
+
8
−
4
View file @
b3f4d08f
...
...
@@ -487,11 +487,15 @@ var Query = {
getAggregationDescription
(
tableMetadata
,
query
,
options
)
{
return
conjunctList
(
Query
.
getAggregations
(
query
).
map
(
aggregation
=>
{
if
(
NamedClause
.
isNamed
(
aggregation
))
{
return
[
NamedClause
.
getName
(
aggregation
)];
}
if
(
AggregationClause
.
isMetric
(
aggregation
))
{
let
metric
=
_
.
findWhere
(
tableMetadata
.
metrics
,
{
id
:
AggregationClause
.
getMetric
(
aggregation
)
});
let
name
=
metric
?
metric
.
name
:
"
[Unknown Metric]
"
;
return
[
options
.
jsx
?
<
span
className
=
"
text-green text-bold
"
>
{
name
}
<
/span> : name]
;
}
switch
(
aggregation
[
0
])
{
case
"
METRIC
"
:
let
metric
=
_
.
findWhere
(
tableMetadata
.
metrics
,
{
id
:
aggregation
[
1
]
});
let
name
=
metric
?
metric
.
name
:
"
[Unknown Metric]
"
;
return
[
options
.
jsx
?
<
span
className
=
"
text-green text-bold
"
>
{
name
}
<
/span> : name]
;
case
"
rows
"
:
return
[
"
Raw data
"
];
case
"
count
"
:
return
[
"
Count
"
];
case
"
cum_count
"
:
return
[
"
Cumulative count
"
];
...
...
This diff is collapsed.
Click to expand it.
frontend/test/unit/lib/query.spec.js
+
20
−
0
View file @
b3f4d08f
import
Query
from
"
metabase/lib/query
"
;
import
{
createQuery
,
AggregationClause
,
BreakoutClause
}
from
"
metabase/lib/query
"
;
const
mockTableMetadata
=
{
display_name
:
"
Order
"
,
fields
:
[
{
id
:
1
,
display_name
:
"
Total
"
}
]
}
describe
(
'
Query
'
,
()
=>
{
describe
(
'
createQuery
'
,
()
=>
{
...
...
@@ -284,6 +290,20 @@ describe('Query', () => {
})
});
describe
(
"
generateQueryDescription
"
,
()
=>
{
it
(
"
should work with multiple aggregations
"
,
()
=>
{
expect
(
Query
.
generateQueryDescription
(
mockTableMetadata
,
{
source_table
:
1
,
aggregation
:
[[
"
count
"
],
[
"
sum
"
,
[
"
field-id
"
,
1
]]]
})).
toEqual
(
"
Orders, Count and Sum of Total
"
)
})
it
(
"
should work with named aggregations
"
,
()
=>
{
expect
(
Query
.
generateQueryDescription
(
mockTableMetadata
,
{
source_table
:
1
,
aggregation
:
[[
"
named
"
,
[
"
sum
"
,
[
"
field-id
"
,
1
]],
"
Revenue
"
]]
})).
toEqual
(
"
Orders, Revenue
"
)
})
})
describe
(
'
AggregationClause
'
,
()
=>
{
...
...
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