From 8007ed82f014a9556431595be394e102c52af3bb Mon Sep 17 00:00:00 2001 From: Camille Villa Date: Wed, 13 Nov 2024 09:33:47 -0800 Subject: [PATCH] Drop retired JobPosition and related models (#1098) Co-authored-by: Camille Villa <5402927+camillevilla@users.noreply.github.com> --- .rubocop_todo.yml | 1 - app/models/job_position.rb | 6 ---- app/models/job_position_category.rb | 6 ---- app/models/job_position_practice.rb | 4 --- app/models/practice.rb | 2 -- .../20241101001348_drop_job_position.rb | 33 +++++++++++++++++++ db/schema.rb | 33 ------------------- db/seeds.rb | 16 --------- .../non_current_facility_ids_2024-11-12.json | 1 + lib/tasks/importer.rake | 29 ---------------- spec/models/job_position_category_spec.rb | 9 ----- spec/models/job_position_practice_spec.rb | 8 ----- spec/models/job_position_spec.rb | 9 ----- spec/models/practice_spec.rb | 2 -- spec/tasks/importer_spec.rb | 4 --- 15 files changed, 34 insertions(+), 129 deletions(-) delete mode 100644 app/models/job_position.rb delete mode 100644 app/models/job_position_category.rb delete mode 100644 app/models/job_position_practice.rb create mode 100644 db/migrate/20241101001348_drop_job_position.rb create mode 100644 lib/assets/non_current_facility_ids_2024-11-12.json delete mode 100644 spec/models/job_position_category_spec.rb delete mode 100644 spec/models/job_position_practice_spec.rb delete mode 100644 spec/models/job_position_spec.rb diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4e3026346..11eb2a8a8 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -944,7 +944,6 @@ Rails/I18nLocaleTexts: Rails/InverseOf: Exclude: - 'app/models/category.rb' - - 'app/models/job_position_category.rb' - 'app/models/page.rb' - 'app/models/practice.rb' diff --git a/app/models/job_position.rb b/app/models/job_position.rb deleted file mode 100644 index 82b9f557a..000000000 --- a/app/models/job_position.rb +++ /dev/null @@ -1,6 +0,0 @@ -class JobPosition < ApplicationRecord - acts_as_list - belongs_to :job_position_category, optional: true - has_many :job_position_practices - has_many :practices, through: :job_position_practices -end diff --git a/app/models/job_position_category.rb b/app/models/job_position_category.rb deleted file mode 100644 index 53a80def2..000000000 --- a/app/models/job_position_category.rb +++ /dev/null @@ -1,6 +0,0 @@ -class JobPositionCategory < ApplicationRecord - acts_as_list - has_many :job_positions - has_many :sub_job_position_categories, class_name: 'JobPositionCategory', foreign_key: 'parent_category_id', dependent: :destroy - belongs_to :parent_category, class_name: 'JobPositionCategory', optional: true -end diff --git a/app/models/job_position_practice.rb b/app/models/job_position_practice.rb deleted file mode 100644 index 3d3cb91df..000000000 --- a/app/models/job_position_practice.rb +++ /dev/null @@ -1,4 +0,0 @@ -class JobPositionPractice < ApplicationRecord - belongs_to :job_position - belongs_to :practice -end diff --git a/app/models/practice.rb b/app/models/practice.rb index 91dc58aa2..24fa4948c 100644 --- a/app/models/practice.rb +++ b/app/models/practice.rb @@ -228,8 +228,6 @@ def self.ransackable_scopes(auth_object = nil) has_many :domain_practices, dependent: :destroy has_many :domains, through: :domain_practices has_many :implementation_timeline_files, dependent: :destroy - has_many :job_position_practices, dependent: :destroy - has_many :job_positions, through: :job_position_practices has_many :photo_files, dependent: :destroy has_many :publications, -> { order(position: :asc) }, dependent: :destroy has_many :risk_mitigations, -> { order(position: :asc) }, dependent: :destroy diff --git a/db/migrate/20241101001348_drop_job_position.rb b/db/migrate/20241101001348_drop_job_position.rb new file mode 100644 index 000000000..52f56f2e2 --- /dev/null +++ b/db/migrate/20241101001348_drop_job_position.rb @@ -0,0 +1,33 @@ +class DropJobPosition < ActiveRecord::Migration[6.1] + def change + drop_table :job_position_categories, force: :cascade do |t| + t.string "name" + t.string "short_name" + t.text "description" + t.integer "position" + t.integer "parent_category_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + drop_table :job_positions, force: :cascade do |t| + t.string "name" + t.string "short_name" + t.text "description" + t.integer "position" + t.bigint "job_position_category_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["job_position_category_id"], name: "index_job_positions_on_job_position_category_id" + end + + drop_table :job_position_practices, force: :cascade do |t| + t.bigint "job_position_id" + t.bigint "practice_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["job_position_id"], name: "index_job_position_practices_on_job_position_id" + t.index ["practice_id"], name: "index_job_position_practices_on_practice_id" + end + end +end diff --git a/db/schema.rb b/db/schema.rb index c072d74c8..d68a2ff5e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -357,36 +357,6 @@ t.index ["practice_id"], name: "index_implementation_timeline_files_on_practice_id" end - create_table "job_position_categories", force: :cascade do |t| - t.string "name" - t.string "short_name" - t.text "description" - t.integer "position" - t.integer "parent_category_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - end - - create_table "job_position_practices", force: :cascade do |t| - t.bigint "job_position_id" - t.bigint "practice_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["job_position_id"], name: "index_job_position_practices_on_job_position_id" - t.index ["practice_id"], name: "index_job_position_practices_on_practice_id" - end - - create_table "job_positions", force: :cascade do |t| - t.string "name" - t.string "short_name" - t.text "description" - t.integer "position" - t.bigint "job_position_category_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["job_position_category_id"], name: "index_job_positions_on_job_position_category_id" - end - create_table "milestones", force: :cascade do |t| t.string "description" t.integer "position" @@ -1288,9 +1258,6 @@ add_foreign_key "domain_practices", "domains" add_foreign_key "domain_practices", "practices" add_foreign_key "implementation_timeline_files", "practices" - add_foreign_key "job_position_practices", "job_positions" - add_foreign_key "job_position_practices", "practices" - add_foreign_key "job_positions", "job_position_categories" add_foreign_key "milestones", "timelines" add_foreign_key "mitigations", "risk_mitigations" add_foreign_key "page_accordion_components", "page_components" diff --git a/db/seeds.rb b/db/seeds.rb index 9f402ea04..bbcd1fe3f 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -110,22 +110,6 @@ Category.find_or_create_by!(name: 'QUERI', short_name: 'queri', description: 'QUERI', parent_category: impact_categories[2]), ] - -_job_positions = [ - JobPosition.find_or_create_by!(name: 'Clinic based nurse', short_name: 'clinic_based_nurse', description: 'Clinic based nurse'), - JobPosition.find_or_create_by!(name: 'Clinic based physician', short_name: 'clinic_based_physician', description: 'Clinic based physician'), - JobPosition.find_or_create_by!(name: 'Hospital based nurse', short_name: 'hospital_based_nurse', description: 'Hospital based nurse'), - JobPosition.find_or_create_by!(name: 'Hospital based physician', short_name: 'hospital_based_physician', description: 'Hospital based physician'), - JobPosition.find_or_create_by!(name: 'Nursing Assistant', short_name: 'nursing_assistant', description: 'Nursing Assistant'), - JobPosition.find_or_create_by!(name: 'Pharmacist', short_name: 'pharmacist', description: 'Pharmacist'), - JobPosition.find_or_create_by!(name: 'Pharmacy Tech', short_name: 'pharmacy_tech', description: 'Pharmacy Tech'), - JobPosition.find_or_create_by!(name: 'Researcher', short_name: 'researcher', description: 'Researcher'), - JobPosition.find_or_create_by!(name: 'Prosthetist', short_name: 'prosthetist', description: 'Prosthetist'), - JobPosition.find_or_create_by!(name: 'Purchasing Agent', short_name: 'purchasing_agent', description: 'Purchasing Agent'), - JobPosition.find_or_create_by!(name: 'Dentist', short_name: 'dentist', description: 'Dentist'), -] - - _clinical_conditions = [ ClinicalCondition.find_or_create_by!(name: 'Back Pain', short_name: 'back_pain', description: 'Back pain'), ClinicalCondition.find_or_create_by!(name: 'Chronic Obstructive Pulmonary Disease (COPD)', short_name: 'copd', description: 'Chronic Obstructive Pulmonary Disease (COPD)'), diff --git a/lib/assets/non_current_facility_ids_2024-11-12.json b/lib/assets/non_current_facility_ids_2024-11-12.json new file mode 100644 index 000000000..9e26dfeeb --- /dev/null +++ b/lib/assets/non_current_facility_ids_2024-11-12.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/lib/tasks/importer.rake b/lib/tasks/importer.rake index d68131beb..04b66627c 100644 --- a/lib/tasks/importer.rake +++ b/lib/tasks/importer.rake @@ -102,7 +102,6 @@ namespace :importer do # developing_facility_types categories clinical_conditions - job_positions ancillary_services departments practice_multimedia_images @@ -319,34 +318,6 @@ def clinical_conditions end -def job_positions - puts "==> Importing Practice: #{@name} Job Positions".light_blue - @practice.job_position_practices.each(&:destroy) - question_fields = { - "Which of the following job titles or positions does this practice impact? (Please select all that apply.)": 10 - } - - question_fields.each do |key, value| - q_index = @questions.index(key.to_s) - end_index = q_index + value - 1 - (q_index..end_index).each do |i| - answer = @answers[i] - next if answer.blank? - - if i == end_index && @given_answers[i] == 'Other (please specify) If more than one answer, please separate with a backslash ("\")' - split_answer = answer.split(/\\/) - split_answer.each do |ans| - job_position = JobPosition.find_or_create_by(name: ans) - JobPositionPractice.create job_position: job_position, practice: @practice unless JobPositionPractice.where(job_position: job_position, practice: @practice).any? - end - else - job_position = JobPosition.find_or_create_by(name: answer) - JobPositionPractice.create job_position: job_position, practice: @practice unless JobPositionPractice.where(job_position: job_position, practice: @practice).any? - end - end - end -end - def ancillary_services puts "==> Importing Practice: #{@name} Ancillary Services".light_blue @practice.ancillary_service_practices.each(&:destroy) diff --git a/spec/models/job_position_category_spec.rb b/spec/models/job_position_category_spec.rb deleted file mode 100644 index e6a9ee198..000000000 --- a/spec/models/job_position_category_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'rails_helper' - -RSpec.describe JobPositionCategory, type: :model do - describe 'associations' do - it { should belong_to(:parent_category).optional } - it { should have_many(:sub_job_position_categories) } - it { should have_many(:job_positions) } - end -end diff --git a/spec/models/job_position_practice_spec.rb b/spec/models/job_position_practice_spec.rb deleted file mode 100644 index 336207d93..000000000 --- a/spec/models/job_position_practice_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'rails_helper' - -RSpec.describe JobPositionPractice, type: :model do - describe 'associations' do - it { should belong_to(:practice) } - it { should belong_to(:job_position) } - end -end diff --git a/spec/models/job_position_spec.rb b/spec/models/job_position_spec.rb deleted file mode 100644 index 5e4064bbd..000000000 --- a/spec/models/job_position_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'rails_helper' - -RSpec.describe JobPosition, type: :model do - describe 'associations' do - it { should belong_to(:job_position_category).optional } - it { should have_many(:job_position_practices) } - it { should have_many(:practices) } - end -end diff --git a/spec/models/practice_spec.rb b/spec/models/practice_spec.rb index cb079b2fd..9a1cc82b6 100644 --- a/spec/models/practice_spec.rb +++ b/spec/models/practice_spec.rb @@ -17,8 +17,6 @@ it { should have_many(:developing_facility_types) } it { should have_many(:domain_practices) } it { should have_many(:domains) } - it { should have_many(:job_position_practices) } - it { should have_many(:job_positions) } it { should have_many(:photo_files) } it { should have_many(:publications) } it { should have_many(:risk_mitigations) } diff --git a/spec/tasks/importer_spec.rb b/spec/tasks/importer_spec.rb index 812913db6..ffe54dfed 100644 --- a/spec/tasks/importer_spec.rb +++ b/spec/tasks/importer_spec.rb @@ -41,10 +41,6 @@ expect(flow3.clinical_conditions.count).to be(4) expect(flow3.clinical_conditions.first.name).to eq('prosthetic devices') - # Job Positions - expect(flow3.job_positions.count).to be(1) - expect(flow3.job_positions.first.name).to eq('Clinic based physician') - # Ancillary Services expect(flow3.ancillary_services.count).to be(1) expect(flow3.ancillary_services.first.name).to eq('Rehabilitation & Prosthetics')