From e6c1d949a2a34ce338f747873d773831f7c86ba7 Mon Sep 17 00:00:00 2001 From: Elliot Date: Fri, 6 Dec 2024 16:06:26 -0500 Subject: [PATCH] Ea/seed ds (#890) * Seed data sources * Don't seed the test DB * Rubocop fixes --- db/seeds.rb | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index c005c9c75..ffdd90511 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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