lib/tasks/fix_nil_ethnicity_arrays.rake
def fix_applicant_ethnicity_array(ethnicities, application, applicant)
      primary = application.primary_applicant ? application.primary_applicant.person_hbx_id : "no_primary_found"
      result = [application.hbx_id, primary, applicant.person_hbx_id, applicant.ethnicity.to_s]
      applicant.ethnicity = ethnicities.compact
      ::FinancialAssistance::Applicant.skip_callback(:update, :after, :propagate_applicant)
      updated = applicant.save(validate: false)
      ::FinancialAssistance::Applicant.set_callback(:update, :after, :propagate_applicant)
      if updated
        result << applicant.ethnicity.to_s
      else
        puts "Failed to save applicant (person_hbx_id): #{applicant.person_hbx_id}"
      end
    end
# - find draft applications that were ingested via ATP (or using provided hbx_id)
# - check and update person ethnicity arrays
# - check and update applicant ethnicity arrays
find draft applications that were ingested via ATP (or using provided hbx_id)
check and update person ethnicity arrays
check and update applicant ethnicity arrays
find draft applications that were ingested via ATP ( or using provided hbx_id ) check and update person ethnicity arrays check and update applicant ethnicity arrays
def fix_applicant_ethnicity_array(ethnicities, application, applicant)
      primary = application.primary_applicant ? application.primary_applicant.person_hbx_id : "no_primary_found"
      result = [application.hbx_id, primary, applicant.person_hbx_id, applicant.ethnicity.to_s]
      applicant.ethnicity = ethnicities.compact
      ::FinancialAssistance::Applicant.skip_callback(:update, :after, :propagate_applicant)
      updated = applicant.save(validate: false)
      ::FinancialAssistance::Applicant.set_callback(:update, :after, :propagate_applicant)
      if updated
        result << applicant.ethnicity.to_s
      else
        puts "Failed to save applicant (person_hbx_id): #{applicant.person_hbx_id}"
      end
    end
def fix_applicant_ethnicity_array ( ethnicities , application , applicant ) primary = application . primary_applicant ? application . primary_applicant . person_hbx_id : "no_primary_found" result = [ application . hbx_id , primary , applicant . person_hbx_id , applicant . ethnicity . to_s ] applicant . ethnicity = ethnicities . compact :: FinancialAssistance :: Applicant . skip_callback ( :update , :after , :propagate_applicant ) updated = applicant . save ( validate : false ) :: FinancialAssistance :: Applicant . set_callback ( :update , :after , :propagate_applicant ) if updated result << applicant . ethnicity . to_s else puts "Failed to save applicant (person_hbx_id): #{applicant.person_hbx_id}" end end
find draft applications that were ingested via ATP (or using provided hbx_id)
 check and update person ethnicity arrays
 check and update applicant ethnicity arrays
find draft applications that were ingested via ATP ( or using provided hbx_id ) check and update person ethnicity arrays check and update applicant ethnicity arrays
ethnicities
application
applicant