Skip to content

Instantly share code, notes, and snippets.

@benoittgt
Created July 24, 2018 13:13
Show Gist options
  • Save benoittgt/224dcfc439dabd94376b8d1ef5f60d56 to your computer and use it in GitHub Desktop.
Save benoittgt/224dcfc439dabd94376b8d1ef5f60d56 to your computer and use it in GitHub Desktop.
refactor Remi worker
# 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
@benoittgt
Copy link
Author

We use airbrake an are quite happy about it. But honeybadger seems good too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment