Retrospring/app/workers/question_worker.rb

21 lines
546 B
Ruby
Raw Normal View History

2020-05-25 09:33:09 -07:00
# frozen_string_literal: true
class QuestionWorker
include Sidekiq::Worker
sidekiq_options queue: :question, retry: false
# @param user_id [Integer] user id passed from Devise
# @param question_id [Integer] newly created question id
2020-05-25 09:33:09 -07:00
def perform(user_id, question_id)
user = User.find(user_id)
user.followers.each do |f|
Inbox.create(user_id: f.id, question_id: question_id, new: true)
end
2020-05-25 09:33:09 -07:00
rescue StandardError => e
logger.info "failed to ask question: #{e.message}"
2021-12-28 09:32:03 -08:00
Sentry.capture_exception(e)
end
end