lib/tasks/fix_nil_ethnicity_arrays.rake
# - 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_person_ethnicity_array(ethnicities, application, person)
      primary = application.primary_applicant ? application.primary_applicant.person_hbx_id : "no_primary_found"
      result = [application.hbx_id, primary, person.hbx_id, person.ethnicity.to_s]
      person.ethnicity = ethnicities.compact
      Person.skip_callback(:update, :after, :person_create_or_update_handler)
      updated = person.save(validate: false)
      Person.set_callback(:update, :after, :person_create_or_update_handler)
      if updated
        result << person.ethnicity.to_s
      else
        puts "Failed to save person (hbx_id): #{person.hbx_id}"
      end
    end
def fix_person_ethnicity_array ( ethnicities , application , person ) primary = application . primary_applicant ? application . primary_applicant . person_hbx_id : "no_primary_found" result = [ application . hbx_id , primary , person . hbx_id , person . ethnicity . to_s ] person . ethnicity = ethnicities . compact Person . skip_callback ( :update , :after , :person_create_or_update_handler ) updated = person . save ( validate : false ) Person . set_callback ( :update , :after , :person_create_or_update_handler ) if updated result << person . ethnicity . to_s else puts "Failed to save person (hbx_id): #{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
person