Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

393 add featured eligibilities local db population script #414

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/sheltertech/db/fixture_populator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def self.create_change_request(resource)
module EligibilityCreator
def self.create
Constants::ELIGIBILITY_NAMES.map do |name|
feature_rank = Constants::ELIGIBILITY_FEATURE_RANKS[name]
feature_rank = Constants::ELIGIBILITY_FEATURE_RANKS[name] || nil
resource_count = Constants::ELIGIBILITY_RESOURCE_COUNTS[name] || 5
eligibility = FactoryBot.create(:eligibility, name: name, feature_rank: feature_rank)
associate_with_random_resources(eligibility, resource_count)
Expand Down
17 changes: 17 additions & 0 deletions lib/tasks/linksf.rake
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ namespace :linksf do

locations = JSON.parse(File.read(File.join(args.dirname, 'locations.json')), symbolize_names: true)
organizations = JSON.parse(File.read(File.join(args.dirname, 'organizations.json')), symbolize_names: true)
eligibilities = JSON.parse(File.read(File.join(args.dirname, 'eligibilities.json')), symbolize_names: true)
eligibilities_services = JSON.parse(File.read(File.join(args.dirname, 'eligibilities_services.json')), symbolize_names: true)

category_names = %w[Shelter Food Medical Hygiene Technology]

Expand Down Expand Up @@ -156,6 +158,21 @@ namespace :linksf do

change_request.save!
end

eligibilities_services_hash = {}
eligibilities_services.each do |es|
eligibilities_services_hash[es[:eligibility_id]] ||= []
eligibilities_services_hash[es[:eligibility_id]] << es[:service_id]
end

eligibilities.each do |eligibility|
el = Eligibility.create(id: eligibility[:id], name: eligibility[:name], feature_rank: eligibility[:feature_rank])
el_service_ids = eligibilities_services_hash[el.id] ||= []
el_service_ids.each do |id|
service = Service.find_by(id: id) || nil
el.services << service if service
end
end
end
end

Expand Down
80 changes: 80 additions & 0 deletions linksf/eligibilities.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
[{"id":1001,"name":"Anyone in Need","feature_rank":null},
{"id":1002,"name":"All Ages","feature_rank":null},
{"id":1003,"name":"Adults (31-54 years old)","feature_rank":null},
{"id":1004,"name":"Young Adults (20-30 years old)","feature_rank":null},
{"id":1005,"name":"Teens (13-19 years old)","feature_rank":null},
{"id":1006,"name":"Infants (0-1 years old)","feature_rank":null},
{"id":1007,"name":"Children (2-12 years old)","feature_rank":null},
{"id":1009,"name":"Active Duty","feature_rank":null},
{"id":1010,"name":"National Guard","feature_rank":null},
{"id":1013,"name":"Refugees","feature_rank":null},
{"id":1014,"name":"Undocumented","feature_rank":null},
{"id":1016,"name":"In Jail","feature_rank":null},
{"id":1017,"name":"All Disabilities","feature_rank":null},
{"id":1018,"name":"Learning Disability","feature_rank":null},
{"id":1019,"name":"Developmental Disability","feature_rank":null},
{"id":1020,"name":"Physical Disability","feature_rank":null},
{"id":1021,"name":"Intellectual Disability","feature_rank":null},
{"id":1022,"name":"Mentally Incapacitated","feature_rank":null},
{"id":1023,"name":"Limited Mobility","feature_rank":null},
{"id":1024,"name":"Deaf or Hard of Hearing","feature_rank":null},
{"id":1025,"name":"Visual Impairment","feature_rank":null},
{"id":1027,"name":"Students","feature_rank":null},
{"id":1028,"name":"Employed","feature_rank":null},
{"id":1029,"name":"Retirement","feature_rank":null},
{"id":1030,"name":"Unemployed","feature_rank":null},
{"id":1031,"name":"Women","feature_rank":null},
{"id":1032,"name":"Men","feature_rank":null},
{"id":1033,"name":"Transgender","feature_rank":null},
{"id":1034,"name":"Foster Youth","feature_rank":null},
{"id":1035,"name":"Pregnant","feature_rank":null},
{"id":1036,"name":"Cancer","feature_rank":null},
{"id":1037,"name":"Alzheimers","feature_rank":null},
{"id":1038,"name":"Seizure Disorder","feature_rank":null},
{"id":1039,"name":"PTSD","feature_rank":null},
{"id":1040,"name":"Terminal Illness","feature_rank":null},
{"id":1041,"name":"Infectious Disease","feature_rank":null},
{"id":1042,"name":"HIV/AIDS","feature_rank":null},
{"id":1043,"name":"Substance Dependency","feature_rank":null},
{"id":1044,"name":"Smoker","feature_rank":null},
{"id":1045,"name":"Opioid Addict","feature_rank":null},
{"id":1046,"name":"Mental Illness","feature_rank":null},
{"id":1047,"name":"Chronic Illness","feature_rank":null},
{"id":1048,"name":"Individuals","feature_rank":null},
{"id":1050,"name":"Families with Babies","feature_rank":null},
{"id":1051,"name":"Single Parent","feature_rank":null},
{"id":1052,"name":"Home Owners","feature_rank":null},
{"id":1053,"name":"Home Renters","feature_rank":null},
{"id":1054,"name":"Homeless","feature_rank":null},
{"id":1055,"name":"Near Homeless","feature_rank":null},
{"id":1056,"name":"Runaways","feature_rank":null},
{"id":1057,"name":"Benefit Recipients","feature_rank":null},
{"id":1058,"name":"Low-Income","feature_rank":null},
{"id":1059,"name":"Uninsured","feature_rank":null},
{"id":1060,"name":"Underinsured","feature_rank":null},
{"id":1061,"name":"Limited English","feature_rank":null},
{"id":1062,"name":"African American","feature_rank":null},
{"id":1063,"name":"Asian","feature_rank":null},
{"id":1064,"name":"Latino","feature_rank":null},
{"id":1065,"name":"Native American","feature_rank":null},
{"id":1066,"name":"LGBTQ","feature_rank":null},
{"id":1067,"name":"Trauma Survivors","feature_rank":null},
{"id":1068,"name":"Abuse or Neglect Survivors","feature_rank":null},
{"id":1069,"name":"Domestic Violence Survivors","feature_rank":null},
{"id":1070,"name":"Human Trafficking Survivors","feature_rank":null},
{"id":1071,"name":"Sexual Assault Survivors","feature_rank":null},
{"id":1072,"name":"San Francisco Residency","feature_rank":null},
{"id":1,"name":"Adoption","feature_rank":null},
{"id":2,"name":"Chinese","feature_rank":null},
{"id":3,"name":"Chinese American","feature_rank":null},
{"id":4,"name":"Disaster Victim","feature_rank":null},
{"id":12,"name":"Young Children","feature_rank":null},
{"id":13,"name":"API","feature_rank":null},
{"id":14,"name":"Imminent Risk of Eviction","feature_rank":null},
{"id":1008,"name":"Seniors (55+ years old)","feature_rank":1},
{"id":5,"name":"Transitional Aged Youth","feature_rank":2},
{"id":1011,"name":"Veterans","feature_rank":3},
{"id":1015,"name":"Ex-Offenders","feature_rank":4},
{"id":1049,"name":"Families","feature_rank":5},
{"id":1012,"name":"Immigrants","feature_rank":6}]

Loading