Created
July 24, 2018 13:13
-
-
Save benoittgt/224dcfc439dabd94376b8d1ef5f60d56 to your computer and use it in GitHub Desktop.
refactor Remi worker
This file contains hidden or 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
# from https://twitter.com/mercier_remi/status/1021669831190433792 | |
class CreateNotificationsWorker | |
include Sidekiq::Worker | |
def perform | |
users = User.all | |
users.each do |user| | |
tasks = user.tasks | |
tasks.each do |task| | |
if task.deadline && task.status == 'pending' && task.notified_user == false | |
@notification = Notification.create!(user_id: user.id, task_id: task.id) | |
task.notified_user = true | |
task.save! | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We use airbrake an are quite happy about it. But honeybadger seems good too.