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
f4db6a42
Unverified
Commit
f4db6a42
authored
6 years ago
by
Cam Saul
Browse files
Options
Downloads
Patches
Plain Diff
Extra logging when Pulses fail to send
parent
74e4e6f3
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
+7
-7
7 additions, 7 deletions
src/metabase/pulse.clj
src/metabase/task/send_pulses.clj
+21
-16
21 additions, 16 deletions
src/metabase/task/send_pulses.clj
with
28 additions
and
23 deletions
src/metabase/pulse.clj
+
7
−
7
View file @
f4db6a42
...
...
@@ -29,16 +29,16 @@
"Execute the query for a single card with CARD-ID. OPTIONS are passed along to `dataset-query`."
[
card-id
&
{
:as
options
}]
{
:pre
[(
integer?
card-id
)]}
(
when-let
[
card
(
Card
:id
card-id,
:archived
false
)]
(
let
[{
:keys
[
creator_id
dataset_query
]}
card
]
(
try
(
try
(
when-let
[
card
(
Card
:id
card-id,
:archived
false
)
]
(
let
[{
:keys
[
creator_id
dataset_query
]}
card
]
{
:card
card
:result
(
qp/process-query-and-save-with-max!
dataset_query
(
merge
{
:executed-by
creator_id,
:context
:pulse,
:card-id
card-id
}
options
))}
(
catch
Throwable
t
(
log/warn
(
format
"Error running
card
query
(%n)
"
card-id
)
t
))
))))
options
))}
))
(
catch
Throwable
t
(
log/warn
t
(
trs
"Error running query
for Card {0}
"
card-id
)))))
(
defn-
database-id
[
card
]
(
or
(
:database_id
card
)
...
...
@@ -230,7 +230,7 @@
(
db/delete!
Pulse
:id
(
:id
pulse
)))
(
for
[
channel-id
channel-ids
:let
[
channel
(
some
#
(
when
(
=
channel-id
(
:id
%
))
%
)
(
:channels
pulse
))]]
:let
[
channel
(
some
#
(
when
(
=
channel-id
(
:id
%
))
%
)
(
:channels
pulse
))]]
(
create-notification
pulse
results
channel
)))))
(
defn
send-pulse!
...
...
This diff is collapsed.
Click to expand it.
src/metabase/task/send_pulses.clj
+
21
−
16
View file @
f4db6a42
...
...
@@ -14,7 +14,8 @@
[
metabase.models
[
pulse
:as
pulse
]
[
pulse-channel
:as
pulse-channel
]
[
setting
:as
setting
]]))
[
setting
:as
setting
]]
[
metabase.util.i18n
:refer
[
trs
]]))
(
declare
send-pulses!
)
...
...
@@ -43,20 +44,23 @@
;; triggers the sending of all pulses which are scheduled to run in the current hour
(
jobs/defjob
SendPulses
[
ctx
]
;; determine what time it is right now (hour-of-day & day-of-week) in reporting timezone
(
let
[
reporting-timezone
(
setting/get
:report-timezone
)
now
(
if
(
empty?
reporting-timezone
)
(
time/now
)
(
time/to-time-zone
(
time/now
)
(
time/time-zone-for-id
reporting-timezone
)))
curr-hour
(
time/hour
now
)
;; joda time produces values of 1-7 here (Mon -> Sun) and we subtract 1 from it to
;; make the values zero based to correspond to the indexes in pulse-channel/days-of-week
curr-weekday
(
->>
(
dec
(
time/day-of-week
now
))
(
get
pulse-channel/days-of-week
)
:id
)
curr-monthday
(
monthday
now
)
curr-monthweek
(
monthweek
now
)]
(
send-pulses!
curr-hour
curr-weekday
curr-monthday
curr-monthweek
)))
(
try
;; determine what time it is right now (hour-of-day & day-of-week) in reporting timezone
(
let
[
reporting-timezone
(
setting/get
:report-timezone
)
now
(
if
(
empty?
reporting-timezone
)
(
time/now
)
(
time/to-time-zone
(
time/now
)
(
time/time-zone-for-id
reporting-timezone
)))
curr-hour
(
time/hour
now
)
;; joda time produces values of 1-7 here (Mon -> Sun) and we subtract 1 from it to
;; make the values zero based to correspond to the indexes in pulse-channel/days-of-week
curr-weekday
(
->>
(
dec
(
time/day-of-week
now
))
(
get
pulse-channel/days-of-week
)
:id
)
curr-monthday
(
monthday
now
)
curr-monthweek
(
monthweek
now
)]
(
send-pulses!
curr-hour
curr-weekday
curr-monthday
curr-monthweek
))
(
catch
Throwable
e
(
log/error
e
(
trs
"SendPulses task failed"
)))))
(
defn
task-init
"Automatically called during startup; start the job for sending pulses."
...
...
@@ -79,7 +83,7 @@
;;; ------------------------------------------------- PULSE SENDING --------------------------------------------------
(
defn-
log-pulse-exception
[
pulse-id
exception
]
(
log/error
"Error sending
p
ulse
:
"
pulse-id
exception
))
(
log/error
exception
(
trs
"Error sending
P
ulse
{0}
"
pulse-id
)
))
(
defn-
send-pulses!
"Send any `Pulses` which are scheduled to run in the current day/hour. We use the current time and determine the
...
...
@@ -95,6 +99,7 @@
(
pulse-channel/day-of-week?
weekday
)
(
contains?
#
{
:first
:last
:mid
:other
}
monthday
)
(
contains?
#
{
:first
:last
:other
}
monthweek
)]}
(
log/info
(
trs
"Sending scheduled pulses..."
))
(
let
[
channels-by-pulse
(
group-by
:pulse_id
(
pulse-channel/retrieve-scheduled-channels
hour
weekday
monthday
monthweek
))]
(
doseq
[
pulse-id
(
keys
channels-by-pulse
)]
(
try
...
...
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