Skip to content

Commit

Permalink
fix tests, add lever to factory, fix dist scopes (#21779)
Browse files Browse the repository at this point in the history
  • Loading branch information
craigrva authored May 31, 2024
1 parent 7bf16f1 commit 7ffc3eb
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 11 deletions.
6 changes: 3 additions & 3 deletions app/models/concerns/distribution_scopes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def generate_genpop_cavc_affinity_days_lever_query
genpop_base_query
.ama_non_aod_appeals
.where(
"appeals.stream_type != ? OR distribution_task.assigned_at <= ?",
"appeals.stream_type != ? OR appeal_affinities.affinity_start_date <= ?",
Constants.AMA_STREAM_TYPES.court_remand,
CaseDistributionLever.cavc_affinity_days.days.ago
)
Expand All @@ -98,7 +98,7 @@ def generate_genpop_cavc_aod_affinity_days_lever_query
genpop_base_query
.ama_aod_appeals
.where(
"appeals.stream_type != ? OR distribution_task.assigned_at < ?",
"appeals.stream_type != ? OR appeal_affinities.affinity_start_date < ?",
Constants.AMA_STREAM_TYPES.court_remand,
CaseDistributionLever.cavc_aod_affinity_days.days.ago
)
Expand Down Expand Up @@ -187,7 +187,7 @@ def with_original_appeal_and_judge_task
# Within the first 21 days, the appeal should be distributed only to the issuing judge.
def non_genpop_for_judge(judge, lever_days = CaseDistributionLever.cavc_affinity_days)
genpop_base_query
.where("appeal_affinities.affinity_start_date > ?", CaseDistributionLever.cavc_affinity_days.days.ago)
.where("appeal_affinities.affinity_start_date > ?", lever_days.days.ago)
.where(original_judge_task: { assigned_to_id: judge&.id })
end

Expand Down
36 changes: 36 additions & 0 deletions spec/factories/case_distribution_lever.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,42 @@
lever_group_order { 3002 }
end

trait :cavc_aod_affinity_days do
item { Constants.DISTRIBUTION.cavc_aod_affinity_days }
title { Constants.DISTRIBUTION.cavc_aod_affinity_days_title }
description do
"Sets the number of days appeals returned from CAVC that are also AOD respect the affinity to the deciding "\
"judge. This is not applicable for legacy apeals for which the deciding judge conducted the most recent"\
"hearing."
end
data_type { Constants.ACD_LEVERS.data_types.radio }
value { "14" }
unit { "days" }
options do
[{
item: Constants.ACD_LEVERS.value,
data_type: Constants.ACD_LEVERS.data_types.number,
value: 14,
text: "Attempt distribution to current judge for max of:",
unit: Constants.ACD_LEVERS.days,
selected: true
},
{
item: Constants.ACD_LEVERS.infinite,
value: Constants.ACD_LEVERS.infinite,
text: "Always distribute to current judge"
},
{
item: Constants.ACD_LEVERS.omit,
value: Constants.ACD_LEVERS.omit,
text: "Omit variable from distribution rules"
}]
end
algorithms_used { [Constants.ACD_LEVERS.algorithms.proportion] }
lever_group { Constants.ACD_LEVERS.lever_groups.affinity }
lever_group_order { 3003 }
end

trait :ama_hearing_case_aod_affinity_days do
item { "ama_hearing_case_aod_affinity_days" }
title { "AMA Hearing Case AOD Affinity Days" }
Expand Down
1 change: 1 addition & 0 deletions spec/jobs/push_priority_appeals_to_judges_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
create(:case_distribution_lever, :nod_adjustment)
create(:case_distribution_lever, :batch_size_per_attorney)
create(:case_distribution_lever, :cavc_affinity_days)
create(:case_distribution_lever, :cavc_aod_affinity_days)
create(:case_distribution_lever, :ama_hearing_case_affinity_days)
create(:case_distribution_lever, :ama_hearing_case_aod_affinity_days)
create(:case_distribution_lever, :ama_direct_review_start_distribution_prior_to_goals)
Expand Down
1 change: 1 addition & 0 deletions spec/models/docket_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
describe Docket, :all_dbs do
before do
create(:case_distribution_lever, :cavc_affinity_days)
create(:case_distribution_lever, :cavc_aod_affinity_days)
create(:case_distribution_lever, :request_more_cases_minimum)
end

Expand Down
14 changes: 6 additions & 8 deletions spec/models/dockets/hearing_request_docket_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@

describe HearingRequestDocket, :postgres do
before do
create(:case_distribution_lever, :ama_hearing_case_affinity_days)
create(:case_distribution_lever, :ama_hearing_case_aod_affinity_days)
# these were the defaut values at time of writing tests but can change over time, so ensure they are
# what the tests were originally written for
create(:case_distribution_lever, :ama_hearing_case_affinity_days, value: "60")
create(:case_distribution_lever, :ama_hearing_case_aod_affinity_days, value: "14")
create(:case_distribution_lever, :cavc_affinity_days, value: "21")
create(:case_distribution_lever, :cavc_aod_affinity_days, value: "14")
create(:case_distribution_lever, :request_more_cases_minimum)
create(:case_distribution_lever, :cavc_affinity_days)

FeatureToggle.enable!(:acd_distribute_by_docket_date)

# these were the defaut values at time of writing tests but can change over time, so ensure they are set
# back to what the tests were originally written for
CaseDistributionLever.find_by_item(Constants.DISTRIBUTION.ama_hearing_case_affinity_days).update!(value: "60")
CaseDistributionLever.find_by_item(Constants.DISTRIBUTION.ama_hearing_case_aod_affinity_days).update!(value: "14")
end

context "#ready_priority_appeals" do
Expand Down

0 comments on commit 7ffc3eb

Please sign in to comment.