Skip to main content
edited tags; edited title
Link
200_success
  • 144.2k
  • 22
  • 188
  • 473

Sidekiq worker in Rubyto validate survey participants

deleted 4 characters in body; edited title
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237

Sidekiq worker ruby codein Ruby

I have worker code that looks like this:

class VerificationWorker
  include Sidekiq::Worker

  def perform(panel_id)
    members = MembersAPI.members.fetch

    members.each do |member|
      survey = Survey.find_by(number: member.data_number)
      next if survey.nil?

      if survey.id != member.data['survey_id']
        survey.fail!('survey_id does not match')
        next
      end

      survey.recipient_id = member.id if survey.recipient_id.blank?
      survey.recipient_id == member.id ? survey.verify! : survey.fail_panel!('recipient_id does not match member id')
    end
  end
end

What do Youyou think about this code? Is it good enough?

Sidekiq worker ruby code

I have worker code that looks like this:

class VerificationWorker
  include Sidekiq::Worker

  def perform(panel_id)
    members = MembersAPI.members.fetch

    members.each do |member|
      survey = Survey.find_by(number: member.data_number)
      next if survey.nil?

      if survey.id != member.data['survey_id']
        survey.fail!('survey_id does not match')
        next
      end

      survey.recipient_id = member.id if survey.recipient_id.blank?
      survey.recipient_id == member.id ? survey.verify! : survey.fail_panel!('recipient_id does not match member id')
    end
  end
end

What do You think about this code? Is it good enough?

Sidekiq worker in Ruby

I have worker code that looks like this:

class VerificationWorker
  include Sidekiq::Worker

  def perform(panel_id)
    members = MembersAPI.members.fetch

    members.each do |member|
      survey = Survey.find_by(number: member.data_number)
      next if survey.nil?

      if survey.id != member.data['survey_id']
        survey.fail!('survey_id does not match')
        next
      end

      survey.recipient_id = member.id if survey.recipient_id.blank?
      survey.recipient_id == member.id ? survey.verify! : survey.fail_panel!('recipient_id does not match member id')
    end
  end
end

What do you think about this code? Is it good enough?

Source Link

Sidekiq worker ruby code

I have worker code that looks like this:

class VerificationWorker
  include Sidekiq::Worker

  def perform(panel_id)
    members = MembersAPI.members.fetch

    members.each do |member|
      survey = Survey.find_by(number: member.data_number)
      next if survey.nil?

      if survey.id != member.data['survey_id']
        survey.fail!('survey_id does not match')
        next
      end

      survey.recipient_id = member.id if survey.recipient_id.blank?
      survey.recipient_id == member.id ? survey.verify! : survey.fail_panel!('recipient_id does not match member id')
    end
  end
end

What do You think about this code? Is it good enough?