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 array
# - check and update applicant ethnicity array
find draft applications that were ingested via ATP (or using provided hbx_id)
check and update person ethnicity array
check and update applicant ethnicity array
find draft applications that were ingested via ATP ( or using provided hbx_id ) check and update person ethnicity array check and update applicant ethnicity array
def fix_person_ethnicity_array(ethnicities, _application, person)
      Person.skip_callback(:update, :after, :person_create_or_update_handler)
      person.ethnicity = ethnicities.compact
      updated = person.save(validate: false)
      Person.set_callback(:update, :after, :person_create_or_update_handler)
      raise StandardError, "Failed to save person (hbx_id): #{person.hbx_id}" unless updated
    rescue StandardError => e
      puts "Error updating peson ethnicity array - #{e}"
    end
def fix_person_ethnicity_array ( ethnicities , _application , person ) Person . skip_callback ( :update , :after , :person_create_or_update_handler ) person . ethnicity = ethnicities . compact updated = person . save ( validate : false ) Person . set_callback ( :update , :after , :person_create_or_update_handler ) raise StandardError , "Failed to save person (hbx_id): #{person.hbx_id}" unless updated rescue StandardError => e puts "Error updating peson ethnicity array - #{e}" end
find draft applications that were ingested via ATP (or using provided hbx_id)
 check and update person ethnicity array
 check and update applicant ethnicity array
find draft applications that were ingested via ATP ( or using provided hbx_id ) check and update person ethnicity array check and update applicant ethnicity array
ethnicities
_application
person