Skip to content

Commit

Permalink
Drop retired JobPosition and related models (#1098)
Browse files Browse the repository at this point in the history
Co-authored-by: Camille Villa <[email protected]>
  • Loading branch information
camillevilla and camillevilla authored Nov 13, 2024
1 parent e628169 commit 8007ed8
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 129 deletions.
1 change: 0 additions & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
6 changes: 0 additions & 6 deletions app/models/job_position.rb

This file was deleted.

6 changes: 0 additions & 6 deletions app/models/job_position_category.rb

This file was deleted.

4 changes: 0 additions & 4 deletions app/models/job_position_practice.rb

This file was deleted.

2 changes: 0 additions & 2 deletions app/models/practice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 33 additions & 0 deletions db/migrate/20241101001348_drop_job_position.rb
Original file line number Diff line number Diff line change
@@ -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
33 changes: 0 additions & 33 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
16 changes: 0 additions & 16 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)'),
Expand Down
1 change: 1 addition & 0 deletions lib/assets/non_current_facility_ids_2024-11-12.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
29 changes: 0 additions & 29 deletions lib/tasks/importer.rake
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ namespace :importer do
# developing_facility_types
categories
clinical_conditions
job_positions
ancillary_services
departments
practice_multimedia_images
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 0 additions & 9 deletions spec/models/job_position_category_spec.rb

This file was deleted.

8 changes: 0 additions & 8 deletions spec/models/job_position_practice_spec.rb

This file was deleted.

9 changes: 0 additions & 9 deletions spec/models/job_position_spec.rb

This file was deleted.

2 changes: 0 additions & 2 deletions spec/models/practice_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down
4 changes: 0 additions & 4 deletions spec/tasks/importer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 8007ed8

Please sign in to comment.