Skip to content

Commit

Permalink
Ea/seed ds (#890)
Browse files Browse the repository at this point in the history
* Seed data sources

* Don't seed the test DB

* Rubocop fixes
  • Loading branch information
eanders authored Dec 6, 2024
1 parent 4680065 commit e6c1d94
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def hud_codes
1 => 'Full name reported',
2 => 'Partial, street name, or code name reported',
8 => 'Client doesn’t know',
9 => 'Client refused'
9 => 'Client refused',
}.each do |id, name|
item = NameQualityCode.where(numeric: id).first_or_create! do |r|
r.numeric = id
Expand All @@ -19,7 +19,7 @@ def hud_codes
2 => 'Approximate or partial SSN reported',
8 => 'Client doesn’t know',
9 => 'Client refused',
99 => 'Data not collected'
99 => 'Data not collected',
}.each do |id, name|
item = SocialSecurityNumberQualityCode.where(numeric: id).first_or_create! do |r|
r.numeric = id
Expand All @@ -34,7 +34,7 @@ def hud_codes
2 => 'Approximate or partial DOB reported',
8 => 'Client doesn’t know',
9 => 'Client refused',
99 => 'Data not collected'
99 => 'Data not collected',
}.each do |id, name|
item = DateOfBirthQualityCode.where(numeric: id).first_or_create! do |r|
r.numeric = id
Expand All @@ -50,7 +50,7 @@ def hud_codes
1 => 'Hispanic/Latino',
8 => 'Client doesn’t know',
9 => 'Client refused',
99 => 'Data not collected'
99 => 'Data not collected',
}.each do |id, name|
item = Ethnicity.where(numeric: id).first_or_create! do |r|
r.numeric = id
Expand All @@ -65,7 +65,7 @@ def hud_codes
1 => 'Yes',
8 => 'Client doesn’t know',
9 => 'Client refused',
99 => 'Data not collected'
99 => 'Data not collected',
}.each do |id, name|
item = VeteranStatus.where(numeric: id).first_or_create! do |r|
r.numeric = id
Expand All @@ -80,7 +80,7 @@ def hud_codes
1 => 'Yes',
8 => 'Client doesn’t know',
9 => 'Client refused',
99 => 'Data not collected'
99 => 'Data not collected',
}.each do |id, name|
item = DisablingCondition.where(numeric: id).first_or_create! do |r|
r.numeric = id
Expand All @@ -92,7 +92,7 @@ def hud_codes

[
'HUD: CoC - Permanent Supportive Housing',
'HUD: CoC - Rapid Re-Housing'
'HUD: CoC - Rapid Re-Housing',
].each do |name|
FundingSource.where(name: name).first_or_create!(name: name)
end
Expand Down Expand Up @@ -143,14 +143,13 @@ def report_list
end

def cleanup_unused_reports
[
].each do |url|
[].each do |url|
ReportDefinition.where(url: url).delete_all
end
end

def maintain_report_definitions
cleanup_unused_reports()
cleanup_unused_reports
report_list.each do |category, reports|
reports.each do |report|
r = ReportDefinition.where(url: report[:url]).first_or_initialize
Expand All @@ -163,9 +162,19 @@ def maintain_report_definitions
end
end

def ensure_data_sources
# We handle these differently in the test world
return if Rails.env.test?

DataSource.where(name: 'Deidentified Clients', db_identifier: 'Deidentified').first_or_create
DataSource.where(name: 'Imported Clients', db_identifier: 'Imported').first_or_create
DataSource.where(name: 'DND Warehouse', db_identifier: 'hmis_warehouse').first_or_create
end

ensure_data_sources
hud_codes
StalledResponse.ensure_all
maintain_report_definitions
# force config refresh
Config.first&.invalidate_cache
Translation::maintain_keys
Translation.maintain_keys

0 comments on commit e6c1d94

Please sign in to comment.