diff --git a/Gemfile.lock b/Gemfile.lock index 3377b991095..2632deaf2e2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1710,6 +1710,7 @@ GEM mime-types-data (3.2019.1009) mini_histogram (0.3.1) mini_mime (1.1.2) + mini_portile2 (2.8.7) minitest (5.19.0) moment_timezone-rails (0.5.0) momentjs-rails (2.29.4.1) @@ -1729,7 +1730,8 @@ GEM net-protocol nio4r (2.5.9) no_proxy_fix (0.1.2) - nokogiri (1.15.5-x86_64-darwin) + nokogiri (1.15.5) + mini_portile2 (~> 2.8.2) racc (~> 1.4) nori (2.6.0) notiffany (0.1.1) @@ -2126,7 +2128,7 @@ GEM ziptz (2.1.6) PLATFORMS - x86_64-darwin-22 + ruby DEPENDENCIES aasm (= 4.11.0) diff --git a/app/models/vacols/case_docket.rb b/app/models/vacols/case_docket.rb index 7810dfbe51b..65c08422380 100644 --- a/app/models/vacols/case_docket.rb +++ b/app/models/vacols/case_docket.rb @@ -835,7 +835,7 @@ def self.cavc_affinity_filter(appeals, judge_sattyid, cavc_affinity_lever_value, reject_due_to_affinity?(appeal, cavc_affinity_lever_value) elsif cavc_affinity_lever_value == Constants.ACD_LEVERS.infinite - next if ineligible_judges_sattyids&.include?(appeal["vlj"]) + next if hearing_judge_ineligible_with_no_hearings_after_decision(appeal) appeal["prev_deciding_judge"] != judge_sattyid elsif cavc_affinity_lever_value == Constants.ACD_LEVERS.omit @@ -867,7 +867,7 @@ def self.cavc_aod_affinity_filter(appeals, judge_sattyid, cavc_aod_affinity_leve reject_due_to_affinity?(appeal, cavc_aod_affinity_lever_value) elsif cavc_aod_affinity_lever_value == Constants.ACD_LEVERS.infinite - next if ineligible_judges_sattyids&.include?(appeal["vlj"]) + next if hearing_judge_ineligible_with_no_hearings_after_decision(appeal) appeal["prev_deciding_judge"] != judge_sattyid elsif cavc_aod_affinity_lever_value == Constants.ACD_LEVERS.omit @@ -921,6 +921,10 @@ def self.reject_due_to_affinity?(appeal, lever) .affinity_start_date > lever.to_i.days.ago) end + def self.hearing_judge_ineligible_with_no_hearings_after_decision(appeal) + ineligible_judges_sattyids&.include?(appeal["vlj"]) && !appeal_has_hearing_after_previous_decision?(appeal) + end + def self.ineligible_judges_sattyids Rails.cache.fetch("case_distribution_ineligible_judges")&.pluck(:sattyid)&.reject(&:blank?) || [] end diff --git a/spec/models/vacols/case_docket_spec.rb b/spec/models/vacols/case_docket_spec.rb index 3af5052a634..073668e37f6 100644 --- a/spec/models/vacols/case_docket_spec.rb +++ b/spec/models/vacols/case_docket_spec.rb @@ -1110,12 +1110,13 @@ def create_case_hearing(original_case, hearing_judge) c end - it "considers cases tied to a judge if they held a hearing after the previous case was decided" do + it "cases are tied to the judge who held a hearing after the previous case was decided", :aggregate_failures do IneligibleJudgesJob.perform_now + # For case distribution levers set to a value + new_hearing_judge_cases = VACOLS::CaseDocket.distribute_priority_appeals(new_hearing_judge, "any", 100, true) tied_judge_cases = VACOLS::CaseDocket.distribute_priority_appeals(tied_judge_caseflow, "any", 100, true) other_judge_cases = VACOLS::CaseDocket.distribute_priority_appeals(other_judge_caseflow, "any", 100, true) - new_hearing_judge_cases = VACOLS::CaseDocket.distribute_priority_appeals(new_hearing_judge, "any", 100, true) expect(new_hearing_judge_cases.map { |c| c["bfkey"] }.sort) .to match_array([ @@ -1131,6 +1132,52 @@ def create_case_hearing(original_case, hearing_judge) .to match_array([ case_7, case_8, case_9, case_10, case_12, case_13 ].map { |c| (c["bfkey"].to_i + 1).to_s }.sort) + + # For case distribution levers set to infinite + CaseDistributionLever.find_by(item: "cavc_affinity_days").update!(value: "infinite") + CaseDistributionLever.find_by(item: "cavc_aod_affinity_days").update!(value: "infinite") + + new_hrng_judge_infinite = VACOLS::CaseDocket.distribute_priority_appeals(new_hearing_judge, "any", 100, true) + tied_judge_infinite = VACOLS::CaseDocket.distribute_priority_appeals(tied_judge_caseflow, "any", 100, true) + other_judge_infinite = VACOLS::CaseDocket.distribute_priority_appeals(other_judge_caseflow, "any", 100, true) + + expect(new_hrng_judge_infinite.map { |c| c["bfkey"] }.sort) + .to match_array([ + case_1, case_2, case_3, case_4, case_5, case_10, case_12 + ].map { |c| (c["bfkey"].to_i + 1).to_s }.sort) + + expect(tied_judge_infinite.map { |c| c["bfkey"] }.sort) + .to match_array([ + case_6, case_9, case_10, case_11, case_12, case_13 + ].map { |c| (c["bfkey"].to_i + 1).to_s }.sort) + + expect(other_judge_infinite.map { |c| c["bfkey"] }.sort) + .to match_array([ + case_7, case_8, case_10, case_12 + ].map { |c| (c["bfkey"].to_i + 1).to_s }.sort) + + # For case distribution levers set to omit + CaseDistributionLever.find_by(item: "cavc_affinity_days").update!(value: "omit") + CaseDistributionLever.find_by(item: "cavc_aod_affinity_days").update!(value: "omit") + + new_hearing_judge_omit = VACOLS::CaseDocket.distribute_priority_appeals(new_hearing_judge, "any", 100, true) + tied_judge_omit = VACOLS::CaseDocket.distribute_priority_appeals(tied_judge_caseflow, "any", 100, true) + other_judge_omit = VACOLS::CaseDocket.distribute_priority_appeals(other_judge_caseflow, "any", 100, true) + + expect(new_hearing_judge_omit.map { |c| c["bfkey"] }.sort) + .to match_array([ + case_1, case_2, case_3, case_4, case_5, case_7, case_8, case_9, case_10, case_11, case_12, case_13 + ].map { |c| (c["bfkey"].to_i + 1).to_s }.sort) + + expect(tied_judge_omit.map { |c| c["bfkey"] }.sort) + .to match_array([ + case_6, case_7, case_8, case_9, case_10, case_11, case_12, case_13 + ].map { |c| (c["bfkey"].to_i + 1).to_s }.sort) + + expect(other_judge_omit.map { |c| c["bfkey"] }.sort) + .to match_array([ + case_7, case_8, case_9, case_10, case_11, case_12, case_13 + ].map { |c| (c["bfkey"].to_i + 1).to_s }.sort) end end end