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
cc51b5f2
Unverified
Commit
cc51b5f2
authored
1 year ago
by
Jerry Huang
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Hide cards in email/slack subscriptions when empty setting (#31451)
* initial changes * add test
parent
faedb8c2
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/pulse.clj
+16
-15
16 additions, 15 deletions
src/metabase/pulse.clj
test/metabase/dashboard_subscription_test.clj
+9
-0
9 additions, 0 deletions
test/metabase/dashboard_subscription_test.clj
with
25 additions
and
15 deletions
src/metabase/pulse.clj
+
16
−
15
View file @
cc51b5f2
...
...
@@ -39,6 +39,17 @@
;;; ------------------------------------------------- PULSE SENDING --------------------------------------------------
(
defn-
is-card-empty?
"Check if the card is empty"
[
card
]
(
if-let
[
result
(
:result
card
)]
(
or
(
zero?
(
->
result
:row_count
))
;; Many aggregations result in [[nil]] if there are no rows to aggregate after filters
(
=
[[
nil
]]
(
->
result
:data
:rows
)))
;; Text cards have no result; treat as empty
true
))
(
defn-
merge-default-values
"For the specific case of Dashboard Subscriptions we should use `:default` parameter values as the actual `:value` for
the parameter if none is specified. Normally the FE client will take `:default` and pass it in as `:value` if it
...
...
@@ -73,10 +84,11 @@
(
qp/process-query-and-save-with-max-results-constraints!
(
assoc
query
:async?
false
)
info
)))]
{
:card
card
:dashcard
dashcard
:result
result
:type
:card
})
(
when-not
(
and
(
get-in
dashcard
[
:visualization_settings
:card.hide_empty
])
(
is-card-empty?
result
))
{
:card
card
:dashcard
dashcard
:result
result
:type
:card
}))
(
catch
Throwable
e
(
log/warn
e
(
trs
"Error running query for Card {0}"
card-or-id
)))))
...
...
@@ -333,17 +345,6 @@
[]
attachments
))))
(
defn-
is-card-empty?
"Check if the card is empty"
[
card
]
(
if-let
[
result
(
:result
card
)]
(
or
(
zero?
(
->
result
:row_count
))
;; Many aggregations result in [[nil]] if there are no rows to aggregate after filters
(
=
[[
nil
]]
(
->
result
:data
:rows
)))
;; Text cards have no result; treat as empty
true
))
(
defn-
are-all-parts-empty?
"Do none of the cards have any results?"
[
results
]
...
...
This diff is collapsed.
Click to expand it.
test/metabase/dashboard_subscription_test.clj
+
9
−
0
View file @
cc51b5f2
...
...
@@ -236,6 +236,15 @@
:result
(
s/pred
map?
)
:type
(
s/eq
:card
)}]
result
)))))
(
testing
"hides empty card when card.hide_empty is true"
(
mt/with-temp*
[
Card
[{
card-id-1
:id
}]
Card
[{
card-id-2
:id
}]
Dashboard
[{
dashboard-id
:id,
:as
dashboard
}
{
:name
"Birdfeed Usage"
}]
DashboardCard
[
_
{
:dashboard_id
dashboard-id
:card_id
card-id-1
}]
DashboardCard
[
_
{
:dashboard_id
dashboard-id
:card_id
card-id-2
:visualization_settings
{
:card.hide_empty
true
}}]
User
[{
user-id
:id
}]]
(
let
[
result
(
@#
'metabase.pulse/execute-dashboard
{
:creator_id
user-id
}
dashboard
)]
(
is
(
=
(
count
result
)
1
)))))
(
testing
"dashboard cards are ordered correctly -- by rows, and then by columns (#17419)"
(
mt/with-temp*
[
Card
[{
card-id-1
:id
}]
Card
[{
card-id-2
:id
}]
...
...
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