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
4c41f848
Unverified
Commit
4c41f848
authored
1 year ago
by
Jerry Huang
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix nils in subscriptions for values in series (#32813)
* replace nils initial code * add test
parent
6e5fd7bd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/metabase/pulse/render/body.clj
+11
-2
11 additions, 2 deletions
src/metabase/pulse/render/body.clj
test/metabase/pulse/render/body_test.clj
+13
-8
13 additions, 8 deletions
test/metabase/pulse/render/body_test.clj
with
24 additions
and
10 deletions
src/metabase/pulse/render/body.clj
+
11
−
2
View file @
4c41f848
...
...
@@ -452,9 +452,17 @@
(
table-fn
some-entries
)])
(
split-at
(
/
(
count
legend-entries
)
2
)
legend-entries
)))])))
(
defn-
replace-nils
[
rows
]
(
mapv
(
fn
[
row
]
(
if
(
nil?
(
first
row
))
(
assoc
row
0
"(empty)"
)
row
))
rows
))
(
s/defmethod
render
:categorical/donut
:-
common/RenderedPulseCard
[
_
render-type
timezone-id
:-
(
s/maybe
s/Str
)
card
dashcard
{
:keys
[
rows
cols
viz-settings
]
:as
data
}]
(
let
[
viz-settings
(
merge
viz-settings
(
:visualization_settings
dashcard
))
(
let
[
rows
(
replace-nils
rows
)
viz-settings
(
merge
viz-settings
(
:visualization_settings
dashcard
))
[
x-axis-rowfn
y-axis-rowfn
]
(
common/graphing-column-row-fns
card
data
)
rows
(
map
(
juxt
(
comp
str
x-axis-rowfn
)
y-axis-rowfn
)
(
common/row-preprocess
x-axis-rowfn
y-axis-rowfn
rows
))
...
...
@@ -792,7 +800,8 @@
Use the combo charts for every chart-type in line area bar because we get multiple chart series for cheaper this way."
[
chart-type
render-type
_timezone-id
card
dashcard
{
:keys
[
cols
rows
viz-settings
]
:as
data
}]
(
let
[
viz-settings
(
merge
viz-settings
(
:visualization_settings
dashcard
))
(
let
[
rows
(
replace-nils
rows
)
viz-settings
(
merge
viz-settings
(
:visualization_settings
dashcard
))
x-axis-rowfn
(
or
(
ui-logic/mult-x-axis-rowfn
card
data
)
#
(
vector
(
first
%
)))
y-axis-rowfn
(
or
(
ui-logic/mult-y-axis-rowfn
card
data
)
#
(
vector
(
second
%
)))
x-rows
(
filter
some?
(
map
x-axis-rowfn
rows
))
...
...
This diff is collapsed.
Click to expand it.
test/metabase/pulse/render/body_test.clj
+
13
−
8
View file @
4c41f848
...
...
@@ -421,11 +421,15 @@
(
render-bar-graph
{
:cols
default-columns
:rows
[[
10.0
1
]
[
5.0
10
]
[
2.50
20
]
[
1.25
nil
]]
:viz-settings
{
:graph.metrics
[
"NumPurchased"
]}}))))
(
testing
"Check to make sure we allow nil values for the y-axis"
(
is
(
has-inline-image?
(
render-bar-graph
{
:cols
default-columns
:rows
[[
10.0
1
]
[
5.0
10
]
[
2.50
20
]
[
nil
30
]]
:viz-settings
{
:graph.metrics
[
"NumPurchased"
]}}))))
(
testing
"Check to make sure we allow nil values for the x-axis"
(
let
[
graph
(
render-bar-graph
{
:cols
default-columns
:rows
[[
10.0
1
]
[
5.0
10
]
[
2.50
20
]
[
nil
30
]]
:viz-settings
{
:graph.metrics
[
"NumPurchased"
]}})]
(
is
(
has-inline-image?
graph
))
(
is
(
=
graph
(
render-bar-graph
{
:cols
default-columns
:rows
[[
10.0
1
]
[
5.0
10
]
[
2.50
20
]
[
"(empty)"
30
]]
:viz-settings
{
:graph.metrics
[
"NumPurchased"
]}})))))
(
testing
"Check to make sure we allow nil values for both x and y on different rows"
(
is
(
has-inline-image?
(
render-bar-graph
{
:cols
default-columns
...
...
@@ -576,15 +580,16 @@
x
))
html-tree
))]
(
testing
"Renders without error"
(
let
[
rendered-info
(
render
[[
"Doohickey"
7
5
]
[
"Widget"
25
]]
{
:show_values
true
})]
(
let
[
rendered-info
(
render
[
[
nil
10
]
[
"Doohickey"
6
5
]
[
"Widget"
25
]]
{
:show_values
true
})]
(
is
(
has-inline-image?
rendered-info
))))
(
testing
"Includes percentages"
(
is
(
=
[
:div
[
:img
]
[
:table
[
:tr
[
:td
[
:span
"•"
]]
[
:td
"Doohickey"
]
[
:td
"75%"
]]
[
:tr
[
:td
[
:span
"•"
]]
[
:td
"(empty)"
]
[
:td
"10%"
]]
[
:tr
[
:td
[
:span
"•"
]]
[
:td
"Doohickey"
]
[
:td
"65%"
]]
[
:tr
[
:td
[
:span
"•"
]]
[
:td
"Widget"
]
[
:td
"25%"
]]]]
(
prune
(
:content
(
render
[[
"Doohickey"
7
5
]
[
"Widget"
25
]]))))))))
(
prune
(
:content
(
render
[
[
nil
10
]
[
"Doohickey"
6
5
]
[
"Widget"
25
]]))))))))
(
deftest
render-progress
(
let
[
col
[{
:name
"NumPurchased"
,
...
...
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