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
8fe0b175
Unverified
Commit
8fe0b175
authored
1 year ago
by
Jerry Huang
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix pulse channel sending n+1 sql calls (#31413)
* initial changes * revert test * fix test
parent
5f6f1d23
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/metabase/task/send_pulses.clj
+12
-7
12 additions, 7 deletions
src/metabase/task/send_pulses.clj
with
12 additions
and
7 deletions
src/metabase/task/send_pulses.clj
+
12
−
7
View file @
8fe0b175
...
...
@@ -7,7 +7,7 @@
[
clojurewerkz.quartzite.schedule.cron
:as
cron
]
[
clojurewerkz.quartzite.triggers
:as
triggers
]
[
metabase.driver
:as
driver
]
[
metabase.models
:refer
[
PulseChannel
PulseChannelRecipient
]]
[
metabase.models
:refer
[
PulseChannel
]]
[
metabase.models.pulse
:as
pulse
]
[
metabase.models.pulse-channel
:as
pulse-channel
]
[
metabase.models.task-history
:as
task-history
]
...
...
@@ -63,14 +63,19 @@
(
catch
Throwable
e
(
on-error
pulse-id
e
)))))))
; Clearing pulse channels is not done synchronously in order to support undoing feature.
(
s/defn
^
:private
clear-pulse-channels!
[]
(
doseq
[
channel
(
t2/select
PulseChannel
)]
(
let
[
pulse-channel-id
(
:id
channel
)]
(
when
(
and
(
nil?
(
get-in
channel
[
:details
:emails
]))
(
nil?
(
get-in
channel
[
:details
:channel
]))
(
zero?
(
t2/count
PulseChannelRecipient
:pulse_channel_id
pulse-channel-id
)))
(
t2/delete!
PulseChannel
:id
pulse-channel-id
)))))
(
when-let
[
ids-to-delete
(
seq
(
for
[
channel
(
t2/select
[
PulseChannel
:id
:details
]
:id
[
:not-in
{
:select
[[
:pulse_channel_id
:id
]]
:from
:pulse_channel_recipient
:group-by
[
:pulse_channel_id
]
:having
[
:>=
:%count.*
[
:raw
1
]]}])]
(
when
(
and
(
empty?
(
get-in
channel
[
:details
:emails
]))
(
not
(
get-in
channel
[
:details
:channel
])))
(
:id
channel
))))]
(
t2/delete!
PulseChannel
:id
[
:in
ids-to-delete
])))
;;; ------------------------------------------------------ Task ------------------------------------------------------
...
...
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