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
4be174bf
Unverified
Commit
4be174bf
authored
1 year ago
by
Cam Saul
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix display name for cumulative count without column (#31271)
parent
6709a06c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/metabase/lib/aggregation.cljc
+26
-13
26 additions, 13 deletions
src/metabase/lib/aggregation.cljc
src/metabase/lib/core.cljc
+3
-1
3 additions, 1 deletion
src/metabase/lib/core.cljc
test/metabase/lib/aggregation_test.cljc
+210
-232
210 additions, 232 deletions
test/metabase/lib/aggregation_test.cljc
with
239 additions
and
246 deletions
src/metabase/lib/aggregation.cljc
+
26
−
13
View file @
4be174bf
...
...
@@ -66,20 +66,34 @@
[
query
stage-number
[
_tag
_opts
index
]
style
]
(
lib.metadata.calculation/display-name
query
stage-number
(
resolve-aggregation
query
stage-number
index
)
style
))
(
defmethod
lib.metadata.calculation/display-name-method
:count
[
query
stage-number
[
_count
_opts
x
]
style
]
(
lib.hierarchy/derive
::count-aggregation
::aggregation
)
;;; count and cumulative count can both be used either with no args (count of rows) or with one arg (count of X, which
;;; I think means count where X is not NULL or something like that. Basically `count(x)` in SQL)
(
doseq
[
tag
[
:count
:cum-count
]]
(
lib.hierarchy/derive
tag
::count-aggregation
))
(
defmethod
lib.metadata.calculation/display-name-method
::count-aggregation
[
query
stage-number
[
tag
_opts
x
]
style
]
;; x is optional.
(
if
x
(
i18n/tru
"Count of {0}"
(
lib.metadata.calculation/display-name
query
stage-number
x
style
))
(
i18n/tru
"Count"
)))
(
let
[
x-display-name
(
lib.metadata.calculation/display-name
query
stage-number
x
style
)]
(
case
tag
:count
(
i18n/tru
"Count of {0}"
x-display-name
)
:cum-count
(
i18n/tru
"Cumulative count of {0}"
x-display-name
)))
(
case
tag
:count
(
i18n/tru
"Count"
)
:cum-count
(
i18n/tru
"Cumulative count"
))))
(
defmethod
lib.metadata.calculation/column-name-method
:count
[
query
stage-number
[
_count
_opts
x
]]
(
if
x
(
str
"count_"
(
lib.metadata.calculation/column-name
query
stage-number
x
))
"count"
))
(
lib.hierarchy/derive
:count
::aggregation
)
[
query
stage-number
[
tag
_opts
x
]]
(
let
[
prefix
(
case
tag
:count
"count"
:cum-count
"cum_count"
)]
(
if
x
(
str
prefix
\_
(
lib.metadata.calculation/column-name
query
stage-number
x
))
prefix
)))
(
defmethod
lib.metadata.calculation/display-name-method
:case
[
_query
_stage-number
_case
_style
]
...
...
@@ -89,10 +103,11 @@
[
_query
_stage-number
_case
]
"case"
)
;;; TODO - Should `:case` derive from `::aggregation` as well???
(
lib.hierarchy/derive
::unary-aggregation
::aggregation
)
(
doseq
[
tag
[
:avg
:cum-count
:cum-sum
:distinct
:max
...
...
@@ -109,7 +124,6 @@
(
str
(
case
tag
:avg
"avg_"
:cum-count
"cum_count_"
:cum-sum
"cum_sum_"
:distinct
"distinct_"
:max
"max_"
...
...
@@ -125,7 +139,6 @@
(
let
[
arg
(
lib.metadata.calculation/display-name
query
stage-number
arg
style
)]
(
case
tag
:avg
(
i18n/tru
"Average of {0}"
arg
)
:cum-count
(
i18n/tru
"Cumulative count of {0}"
arg
)
:cum-sum
(
i18n/tru
"Cumulative sum of {0}"
arg
)
:distinct
(
i18n/tru
"Distinct values of {0}"
arg
)
:max
(
i18n/tru
"Max of {0}"
arg
)
...
...
This diff is collapsed.
Click to expand it.
src/metabase/lib/core.cljc
+
3
−
1
View file @
4be174bf
...
...
@@ -73,7 +73,9 @@
stddev
sum
sum-where
var
]
var
cum-count
cum-sum
]
[
lib.binning
available-binning-strategies
binning
...
...
This diff is collapsed.
Click to expand it.
test/metabase/lib/aggregation_test.cljc
+
210
−
232
View file @
4be174bf
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