Class: HCA::LogEmailDiffJob
- Inherits:
-
Object
- Object
- HCA::LogEmailDiffJob
- Includes:
- Sidekiq::Job
- Defined in:
- app/sidekiq/hca/log_email_diff_job.rb
Instance Method Summary collapse
- #log_email_difference(in_progress_form_id, user_uuid) ⇒ Object
- #log_email_difference_redis(in_progress_form_id, user_uuid) ⇒ Object
- #perform(in_progress_form_id, user_uuid) ⇒ Object
Instance Method Details
#log_email_difference(in_progress_form_id, user_uuid) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/sidekiq/hca/log_email_diff_job.rb', line 40 def log_email_difference(in_progress_form_id, user_uuid) return if FormEmailMatchesProfileLog.exists?(user_uuid:, in_progress_form_id:) in_progress_form = InProgressForm.find_by(id: in_progress_form_id) return if in_progress_form.nil? parsed_form = JSON.parse(in_progress_form.form_data) form_email = parsed_form['email'] email_confirmation = parsed_form['view:email_confirmation'] return if form_email.blank? || form_email != email_confirmation user = User.find(user_uuid) va_profile_email = user.va_profile_email tag_text = va_profile_email&.downcase == form_email.downcase ? 'same' : 'different' StatsD.increment( "api.1010ez.in_progress_form_email.#{tag_text}" ) FormEmailMatchesProfileLog.create(user_uuid:, in_progress_form_id:) end |
#log_email_difference_redis(in_progress_form_id, user_uuid) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/sidekiq/hca/log_email_diff_job.rb', line 16 def log_email_difference_redis(in_progress_form_id, user_uuid) redis_key = "HCA::LogEmailDiffJob:#{user_uuid}" return if $redis.get(redis_key).present? in_progress_form = InProgressForm.find_by(id: in_progress_form_id) return if in_progress_form.nil? parsed_form = JSON.parse(in_progress_form.form_data) form_email = parsed_form['email'] email_confirmation = parsed_form['view:email_confirmation'] return if form_email.blank? || form_email != email_confirmation user = User.find(user_uuid) va_profile_email = user.va_profile_email tag_text = va_profile_email&.downcase == form_email.downcase ? 'same' : 'different' StatsD.increment( "api.1010ez.in_progress_form_email.#{tag_text}" ) $redis.set(redis_key, 't') end |
#perform(in_progress_form_id, user_uuid) ⇒ Object
8 9 10 11 12 13 14 |
# File 'app/sidekiq/hca/log_email_diff_job.rb', line 8 def perform(in_progress_form_id, user_uuid) if Flipper.enabled?(:hca_log_email_diff_in_progress_form) log_email_difference(in_progress_form_id, user_uuid) else log_email_difference_redis(in_progress_form_id, user_uuid) end end |