Fixes, workers now output to sidekiq, not rails
This commit is contained in:
parent
92bbfef2df
commit
26a517a650
|
@ -59,6 +59,7 @@ class Ajax::QuestionController < ApplicationController
|
|||
end
|
||||
elsif params[:rcpt].start_with? 'grp:'
|
||||
unless current_user.nil?
|
||||
begin
|
||||
current_user.groups.find_by_name!(params[:rcpt].sub 'grp:', '')
|
||||
QuestionWorker.perform_async params[:rcpt], current_user.id, question.id
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
|
|
|
@ -8,7 +8,7 @@ class DeletionWorker
|
|||
begin
|
||||
User.find(resource_id).destroy!
|
||||
rescue => e
|
||||
Rails.logger.error "failed to delete user: #{e.message}"
|
||||
logger.error "failed to delete user: #{e.message}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,21 +3,23 @@ class QuestionWorker
|
|||
|
||||
sidekiq_options queue: :question, retry: false
|
||||
|
||||
# @param resource_id [Integer] user id passed from Devise
|
||||
# @param rcpt [Integer] string recipient
|
||||
# @param user_id [Integer] user id passed from Devise
|
||||
# @param question_id [Integer] newly created question id
|
||||
def perform(rcpt, user_id, question_id)
|
||||
begin
|
||||
user = User.find(user_id)
|
||||
if params[:rcpt].start_with? 'grp:'
|
||||
if rcpt == 'followers'
|
||||
user.followers.each do |f|
|
||||
Inbox.create!(user_id: fid, question_id: question_id, new: true)
|
||||
Inbox.create(user_id: fid, question_id: question_id, new: true)
|
||||
end
|
||||
else
|
||||
current_user.groups.find_by_name!(params[:rcpt].sub 'grp:', '').members.each do |m|
|
||||
Inbox.create!(user_id: m.user.id, question_id: question.id, new: true)
|
||||
elsif rcpt.start_with? 'grp:'
|
||||
current_user.groups.find_by_name!(rcpt.sub 'grp:', '').members.each do |m|
|
||||
Inbox.create(user_id: m.user.id, question_id: question.id, new: true)
|
||||
end
|
||||
end
|
||||
rescue => e
|
||||
Rails.logger.error "failed to answer question: #{e.message}"
|
||||
logger.error "failed to ask question: #{e.message}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@ class ShareWorker
|
|||
begin
|
||||
service.post(Answer.find(answer_id)) if services.include? service.provider
|
||||
rescue => e
|
||||
Rails.logger.error "failed to post answer #{answer_id} to #{service.provider} for user #{user_id}: #{e.message}"
|
||||
logger.error "failed to post answer #{answer_id} to #{service.provider} for user #{user_id}: #{e.message}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue