-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
79fa9fb
commit 9bdc15c
Showing
15 changed files
with
81 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
class CompleteRegistrationMailJob < DuplicateJobChecker | ||
class CompleteRegistrationMailJob < ScheduledJob | ||
def run | ||
Rails.logger.info('CompleteRegistrationMailJob running') | ||
NudgeMail.new.complete_registration | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
class ContinueTrainingMailJob < DuplicateJobChecker | ||
class ContinueTrainingMailJob < ScheduledJob | ||
def run | ||
Rails.logger.info('ContinueTrainingMailJob running') | ||
NudgeMail.new.continue_training | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
class ScheduledJob < Que::Job | ||
def run | ||
log "#{self.class.name} running" | ||
if duplicate_job_queued? | ||
log_duplicate | ||
return | ||
end | ||
|
||
super | ||
end | ||
|
||
private | ||
|
||
def duplicate_job_queued? | ||
Que.job_stats.any? { |job| job[:job_class] == self.class.name && job[:count] > 1 } | ||
end | ||
|
||
# @return [String] | ||
def log_duplicate | ||
message = "Duplicate #{self.class.name} job queued - skipping" | ||
Sentry.capture_message(message) if Rails.application.live? | ||
log(message) | ||
end | ||
|
||
def handle_error(error) | ||
message = "#{self.class.name} failed with '#{error.message}'" | ||
log(message) | ||
Sentry.capture_message(message) if Rails.application.live? | ||
end | ||
|
||
# @return [String] | ||
def log(message) | ||
if ENV['RAILS_LOG_TO_STDOUT'].present? | ||
Rails.logger.info(message) | ||
else | ||
# rubocop:disable Rails/Output | ||
puts message | ||
# rubocop:enable Rails/Output | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
class StartTrainingMailJob < DuplicateJobChecker | ||
class StartTrainingMailJob < ScheduledJob | ||
def run | ||
Rails.logger.info('StartTrainingMailJob running') | ||
NudgeMail.new.start_training | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters