Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/appeals 44915.uat 4.4.0 #22658

Merged
merged 47 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
590e2d5
Add in appeals_tied_to_non_ssc_avljs methods and SQL
zurbergram Apr 29, 2024
443b900
Merge branch 'master' into feature/APPEALS-44915
zurbergram May 15, 2024
5a45868
Merge branch 'master' of https://github.com/department-of-veterans-af…
zurbergram Jun 14, 2024
6b0448f
Update case_docket.rb
zurbergram Jun 17, 2024
da4aee3
Update case_docket.rb
zurbergram Jun 17, 2024
38d0b12
Merge branch 'master' into feature/APPEALS-44915
amybids Jul 12, 2024
767610f
APPEALS-51263 added the lever to the seeds file (#22149)
amybids Jul 15, 2024
76c6a15
Amybids/appeals 51263 (#22169)
amybids Jul 15, 2024
6896be6
Merge branch 'master' into feature/APPEALS-44915
amybids Jul 16, 2024
209f590
APPEALS-51262 (#22176)
Blake-Manus Jul 18, 2024
4bba3f3
APPEALS-45232. Added table in the DB and added requested columns (#22…
SHarshain Jul 19, 2024
65f099f
Sharsha/appeals 45200 (#22233)
SHarshain Jul 23, 2024
0e45ff4
Chrisbdetlef/appeals 45208 (#22305)
cdetlefva Jul 25, 2024
33d1aa4
Merge branch 'master' into feature/APPEALS-44915
amybids Jul 31, 2024
8928874
APPEALS-45202.Added button to trigger the job and return the appeals …
SHarshain Aug 1, 2024
b73a390
Updates slack_service.rb to include local/demo console printout messa…
mbeardy Aug 2, 2024
23ce181
APPEALS-51487 Location 63 Query (#22398)
cdetlefva Aug 7, 2024
d666cf1
APPEALS-45248 ACD Controls Test Page Alerts for Run Seed Fils and Cas…
kristeja Aug 7, 2024
28b59f8
Ricky/APPEALS-45204 (#22373)
Blake-Manus Aug 8, 2024
31e2ba8
Ricky/APPEALS-45204 (#22452)
Blake-Manus Aug 12, 2024
68b16c3
Chrisbdetlef/appeals 54138 (#22460)
cdetlefva Aug 12, 2024
73ce37f
Fix for routing table (#22466)
cdetlefva Aug 13, 2024
8663f4f
merged master
amybids Aug 13, 2024
b009c7c
Chrisbdetlef/appeals 54138.1 (#22486)
cdetlefva Aug 14, 2024
77fd64a
Updated query to correctly grab seed data (#22489)
Blake-Manus Aug 14, 2024
60db02a
Ricky/APPEALS-51260 (#22497)
Blake-Manus Aug 15, 2024
c5de24a
APPEALS-54884. spec fix push priority appeals to judges job (#22505)
SHarshain Aug 15, 2024
93faafa
exchanges spaces for hyphens, updates method to filter by unique vete…
mbeardy Aug 16, 2024
2d26492
updates seed file names to match AC and adds hyphens instead of space…
mbeardy Aug 19, 2024
fd354a3
Chrisbdetlef/appeals 54152 (#22531)
cdetlefva Aug 19, 2024
b5421e4
APPEALS-54152.1 Fix issues with the process of making and moving appe…
cdetlefva Aug 20, 2024
da55c06
Chrisbdetlef/appeals 54152.1 (#22544)
cdetlefva Aug 20, 2024
38674f3
Chrisbdetlef/appeals 54152.2 (#22554)
cdetlefva Aug 21, 2024
58d8739
Merge branch 'master' into feature/APPEALS-44915
amybids Aug 22, 2024
6b3937b
Code changes to account for duplicates from base query (#22582)
cdetlefva Aug 22, 2024
38a2b24
mbeard/APPEALS-45203 (#22565)
mbeardy Aug 23, 2024
72e627a
Fix the last name issue on loc 63 CSV (#22591)
cdetlefva Aug 23, 2024
a4a5762
APPEALS-45248 v2 ACD Controls Test Page Alerts for Run Seed Fils and …
kristeja Aug 24, 2024
50bf38d
APPEALS-APPEALS-55680 added nil checking to the return legacy to appe…
amybids Aug 26, 2024
a6a9e99
mbeard/APPEALS-55179 (#22615)
mbeardy Aug 27, 2024
f69cf4c
mbeard/APPEALS-45203 (#22626)
mbeardy Aug 27, 2024
18cae49
APPEALS-54290 CSV for all tied VLJ cases (#22624)
cdetlefva Aug 27, 2024
1fa34a6
APPEALS-56033 fixed duplicate, nil, and error handling (#22630)
amybids Aug 27, 2024
f2916d8
Amybids/appeals 56033 (#22635)
amybids Aug 28, 2024
c05fdef
Fix off by 1 error for returntoboard job (#22648)
cdetlefva Aug 29, 2024
7a510c3
mbeard/APPEALS-55660 (#22653)
mbeardy Aug 29, 2024
ea8d3e0
fixed merge conflict
amybids Aug 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions app/jobs/return_legacy_appeals_to_board_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,20 @@ class ReturnLegacyAppealsToBoardJob < CaseflowJob

queue_as :low_priority
application_attr :queue
NO_RECORDS_MOVED_MESSAGE = [Constants.DISTRIBUTION.no_records_moved_message].freeze

def initialize
@no_records_found_message = [Constants.DISTRIBUTION.no_records_moved_message].freeze
@nonsscavlj_number_of_appeals_limit = CaseDistributionLever.nonsscavlj_number_of_appeals_to_move || 0
@nonsscavlj_number_of_appeals_to_move = @nonsscavlj_number_of_appeals_limit - 1
end

def perform
begin
returned_appeal_job = create_returned_appeal_job

appeals, moved_appeals = eligible_and_moved_appeals

return send_job_slack_report(NO_RECORDS_MOVED_MESSAGE) if moved_appeals.nil?
return send_job_slack_report(@no_records_found_message) if moved_appeals.nil?

complete_returned_appeal_job(returned_appeal_job, "Job completed successfully", moved_appeals)

Expand Down Expand Up @@ -74,10 +79,6 @@ def count_unique_bfkeys(appeals)

private

def max_appeals_to_move
CaseDistributionLever.nonsscavlj_number_of_appeals_to_move
end

def move_qualifying_appeals(appeals)
qualifying_appeals_bfkeys = []

Expand Down Expand Up @@ -113,13 +114,11 @@ def get_tied_appeal_bfkeys(tied_appeals)
end

def update_qualifying_appeals_bfkeys(tied_appeals_bfkeys, qualifying_appeals_bfkeys)
max_appeals = max_appeals_to_move

if tied_appeals_bfkeys.any?
if tied_appeals_bfkeys.count < max_appeals
if tied_appeals_bfkeys.count < @nonsscavlj_number_of_appeals_limit
qualifying_appeals_bfkeys.push(tied_appeals_bfkeys)
else
qualifying_appeals_bfkeys.push(tied_appeals_bfkeys[0..max_appeals])
qualifying_appeals_bfkeys.push(tied_appeals_bfkeys[0..@nonsscavlj_number_of_appeals_to_move])
end
end

Expand Down
11 changes: 11 additions & 0 deletions spec/factories/case_distribution_lever.rb
Original file line number Diff line number Diff line change
Expand Up @@ -500,5 +500,16 @@
lever_group_order { 103 }
control_group { "priority" }
end

trait :nonsscavlj_number_of_appeals_to_move do
item { "nonsscavlj_number_of_appeals_to_move" }
title { "Non-SSC/AVLJ Number of Appeals to Move" }
data_type { "number" }
value { 2 }
unit { "" }
algorithms_used { [] }
lever_group { "internal" }
lever_group_order { 999 }
end
end
end
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 @@ -13,6 +13,7 @@
create(:case_distribution_lever, :ama_hearing_case_aod_affinity_days)
create(:case_distribution_lever, :ama_direct_review_start_distribution_prior_to_goals)
create(:case_distribution_lever, :disable_legacy_non_priority)
create(:case_distribution_lever, :nonsscavlj_number_of_appeals_to_move)
end

def to_judge_hash(arr)
Expand Down Expand Up @@ -230,7 +231,7 @@
allow_any_instance_of(PushPriorityAppealsToJudgesJob).to receive(:eligible_judges).and_return(eligible_judges)
end

xit "should only distribute the ready priority cases tied to a judge" do

Check warning on line 234 in spec/jobs/push_priority_appeals_to_judges_job_spec.rb

View workflow job for this annotation

GitHub Actions / caseflow_rspec_job (12, 5)

PushPriorityAppealsToJudgesJob.distribute_non_genpop_priority_appeals using Automatic Case Distribution module should only distribute the ready priority cases tied to a judge Skipped: Temporarily skipped with xit
expect(subject.count).to eq eligible_judges.count
expect(subject.map { |dist| dist.statistics["batch_size"] }).to match_array [2, 2, 0, 0]

Expand Down Expand Up @@ -262,7 +263,7 @@
create(:case_distribution_lever, :disable_legacy_priority, value: "false")
end

xit "should only distribute the ready priority cases tied to a judge" do

Check warning on line 266 in spec/jobs/push_priority_appeals_to_judges_job_spec.rb

View workflow job for this annotation

GitHub Actions / caseflow_rspec_job (12, 5)

PushPriorityAppealsToJudgesJob.distribute_non_genpop_priority_appeals using By Docket Date Distribution module without using Docket Levers should only distribute the ready priority cases tied to a judge Skipped: Temporarily skipped with xit
expect(subject.count).to eq eligible_judges.count
expect(subject.map { |dist| dist.statistics["batch_size"] }).to match_array [2, 2, 0, 0]

Expand All @@ -288,7 +289,7 @@
create(:case_distribution_lever, :disable_ama_priority_evidence_submission, value: "false")
end

xit "should distribute the ready priority cases" do

Check warning on line 292 in spec/jobs/push_priority_appeals_to_judges_job_spec.rb

View workflow job for this annotation

GitHub Actions / caseflow_rspec_job (12, 5)

PushPriorityAppealsToJudgesJob.distribute_non_genpop_priority_appeals using By Docket Date Distribution module using Excluding Appeals by Docket Type and Priority from Automatic Case Distribution levers all Exluding levers turned to Include should distribute the ready priority cases Skipped: Temporarily skipped with xit
expect(subject.count).to eq eligible_judges.count
expect(subject.map { |dist| dist.statistics["batch_size"] }).to match_array [2, 2, 0, 0]

Expand All @@ -312,7 +313,7 @@
create(:case_distribution_lever, :disable_ama_priority_evidence_submission, value: "true")
end

xit "should not distribute the ready priority cases" do

Check warning on line 316 in spec/jobs/push_priority_appeals_to_judges_job_spec.rb

View workflow job for this annotation

GitHub Actions / caseflow_rspec_job (12, 5)

PushPriorityAppealsToJudgesJob.distribute_non_genpop_priority_appeals using By Docket Date Distribution module using Excluding Appeals by Docket Type and Priority from Automatic Case Distribution levers all Exluding levers turned to Exclude should not distribute the ready priority cases Skipped: Temporarily skipped with xit
expect(subject.count).to eq eligible_judges.count
expect(subject.map { |dist| dist.statistics["batch_size"] }).to match_array [0, 0, 0, 0]

Expand Down
94 changes: 54 additions & 40 deletions spec/jobs/return_legacy_appeals_to_board_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,61 +3,75 @@
describe ReturnLegacyAppealsToBoardJob, :all_dbs do
describe "#perform" do
let(:job) { described_class.new }
context "when successful" do
it "creates a ReturnedAppealJob instance and updates its status" do
expect do
job.perform
end.to change { ReturnedAppealJob.count }.by(1)
let(:returned_appeal_job) { instance_double("ReturnedAppealJob", id: 1) }
let(:appeals) { [{ "bfkey" => "1", "priority" => 1 }, { "bfkey" => "2", "priority" => 0 }] }
let(:moved_appeals) { [{ "bfkey" => "1", "priority" => 1 }] }

returned_appeal_job = ReturnedAppealJob.last
expect(returned_appeal_job.started_at).to be_present
before do
allow(CaseDistributionLever).to receive(:nonsscavlj_number_of_appeals_to_move).and_return(2)

if returned_appeal_job.errored_at
expect(JSON.parse(returned_appeal_job.stats)["message"]).to include("Job failed with error")
else
expect(returned_appeal_job.completed_at).to be_present
expect(JSON.parse(returned_appeal_job.stats)["message"]).to eq("Job completed successfully")
end
end
allow(job).to receive(:create_returned_appeal_job).and_return(returned_appeal_job)
allow(returned_appeal_job).to receive(:update!)
allow(job).to receive(:eligible_and_moved_appeals).and_return([appeals, moved_appeals])
allow(job).to receive(:filter_appeals).and_return({})
allow(job).to receive(:send_job_slack_report)
allow(job).to receive(:complete_returned_appeal_job)
allow(job).to receive(:metrics_service_report_runtime)
end

context "when the job completes successfully" do
it "creates a ReturnedAppealJob instance, processes appeals, and sends a report" do
allow(job).to receive(:slack_report).and_return(["Job completed successfully"])

job.perform

it "records runtime metrics" do
allow(MetricsService).to receive(:record_runtime)
expect do
job.perform
end.to change { ReturnedAppealJob.count }.by(1)
expect(MetricsService).to have_received(:record_runtime).with(
hash_including(metric_group: "return_legacy_appeals_to_board_job")
)
expect(job).to have_received(:create_returned_appeal_job).once
expect(job).to have_received(:eligible_and_moved_appeals).once
expect(job).to have_received(:complete_returned_appeal_job)
.with(returned_appeal_job, "Job completed successfully", moved_appeals).once
expect(job).to have_received(:send_job_slack_report).with(["Job completed successfully"]).once
expect(job).to have_received(:metrics_service_report_runtime)
.with(metric_group_name: "return_legacy_appeals_to_board_job").once
end
end

context "when an error occurs" do
let(:error_message) { "Something went wrong" }

context "when no appeals are moved" do
before do
allow(job).to receive(:send_job_slack_report).and_raise(StandardError, error_message)
allow(job).to receive(:eligible_and_moved_appeals).and_return([appeals, nil])
allow(job).to receive(:slack_report).and_return(["Job Ran Successfully, No Records Moved"])
end

it "updates the ReturnedAppealJob with error details" do
expect do
job.perform
end.to change { ReturnedAppealJob.count }.by(1)
it "sends a no records moved Slack report" do
job.perform

returned_appeal_job = ReturnedAppealJob.last
expect(returned_appeal_job.errored_at).to be_present
expect(JSON.parse(returned_appeal_job.stats)["message"]).to include("Job failed with error")
expect(job).to have_received(:send_job_slack_report).with(["Job Ran Successfully, No Records Moved"]).once
expect(job).to have_received(:metrics_service_report_runtime).once
end
end

it "sends an error notification via Slack" do
expect_any_instance_of(SlackService).to receive(:send_notification).with(
a_string_matching(/<!here>\n \[ERROR\]/), job.class.name
)
job.perform
context "when an error occurs" do
let(:error_message) { "Unexpected error" }
let(:slack_service_instance) { instance_double(SlackService) }

before do
allow(job).to receive(:eligible_and_moved_appeals).and_raise(StandardError, error_message)
allow(job).to receive(:log_error)
allow(returned_appeal_job).to receive(:update!)
allow(SlackService).to receive(:new).and_return(slack_service_instance)
allow(slack_service_instance).to receive(:send_notification)
end

it "logs the error" do
expect(job).to receive(:log_error).with(anything)
it "handles the error, logs it, and sends a Slack notification" do
job.perform

expect(job).to have_received(:log_error).with(instance_of(StandardError))
expect(returned_appeal_job).to have_received(:update!)
.with(hash_including(errored_at: kind_of(Time),
stats: "{\"message\":\"Job failed with error: #{error_message}\"}")).once
expect(slack_service_instance).to have_received(:send_notification).with(
a_string_matching(/<!here>\n \[ERROR\]/), job.class.name
).once
expect(job).to have_received(:metrics_service_report_runtime).once
end
end
end
Expand Down
Loading