Skip to content

Instantly share code, notes, and snippets.

@MartianLee
Created January 29, 2019 17:12
Show Gist options
  • Save MartianLee/876aeb44c1d91389d29206c33c65b8e4 to your computer and use it in GitHub Desktop.
Save MartianLee/876aeb44c1d91389d29206c33c65b8e4 to your computer and use it in GitHub Desktop.
유저의 프로필을 갱신하는 job을 생성합니다.
class UserBroadcastJob < ApplicationJob
include Sidekiq::Worker
def perform(user_id)
begin
user = User.find_by(id: user_id)
return if user.blank?
stages = user.meeting.stages
stages.each do |stage|
if stage.polls.present?
ActionCable.server.broadcast("poll_dashboard_channel-#{user.meeting.id}", {
action: 'update_user_image',
poll_id: stage.polls.first.id,
user_id: user.id,
image_path: user.image_url(:sm)
})
end
end
rescue => e
Rails.logger.error 'Error code: UserBroadcastJob'
Rails.logger.error e.message
Rails.logger.error e.backtrace.join("\n")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment