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

Update ReturnLegacyAppealsToBoardJob to use AojLegacyDocket #22975

Merged
merged 9 commits into from
Oct 8, 2024
2 changes: 1 addition & 1 deletion app/jobs/return_legacy_appeals_to_board_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def filter_appeals(appeals, moved_appeals)
end

def eligible_and_moved_appeals
appeals = LegacyDocket.new.appeals_tied_to_non_ssc_avljs
appeals = LegacyDocket.new.appeals_tied_to_non_ssc_avljs + AojLegacyDocket.new.appeals_tied_to_non_ssc_avljs
moved_appeals = move_qualifying_appeals(appeals)
[appeals, moved_appeals]
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/dockets/aoj_legacy_docket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ def non_priority_appeals_affinity_date_count(in_window)
LegacyAppeal.aoj_appeal_repository.non_priority_appeals_affinity_date_count(in_window).size
end

def appeals_tied_to_non_ssc_avljs
LegacyAppeal.aoj_appeal_repository.appeals_tied_to_non_ssc_avljs
end

private

def counts_by_priority_and_readiness
Expand Down
55 changes: 49 additions & 6 deletions app/models/vacols/aoj_case_docket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,39 @@ class VACOLS::AojCaseDocket < VACOLS::CaseDocket # rubocop:disable Metrics/Class
)
"

# this query should not be used during distribution it is only intended for reporting usage
# selects both priority and non-priority appeals that are ready to distribute
SELECT_READY_TO_DISTRIBUTE_APPEALS_ORDER_BY_BFD19 = "
select APPEALS.BFKEY, APPEALS.TINUM, APPEALS.BFD19, APPEALS.BFDLOOUT,
case when APPEALS.PREV_TYPE_ACTION = '7' or APPEALS.AOD = 1 then 1 else 0 end PRIORITY,
APPEALS.VLJ, APPEALS.PREV_DECIDING_JUDGE, APPEALS.HEARING_DATE, APPEALS.PREV_BFDDEC
from (
select BRIEFF.BFKEY, BRIEFF.TINUM, BFD19, BFDLOOUT, BFAC, AOD,
case when BFHINES is null or BFHINES <> 'GP' then VLJ_HEARINGS.VLJ end VLJ
, PREV_APPEAL.PREV_DECIDING_JUDGE PREV_DECIDING_JUDGE
, VLJ_HEARINGS.HEARING_DATE HEARING_DATE
, PREV_APPEAL.PREV_BFDDEC PREV_BFDDEC
, PREV_APPEAL.PREV_TYPE_ACTION
from (
#{SELECT_READY_APPEALS}
) BRIEFF
#{JOIN_ASSOCIATED_VLJS_BY_HEARINGS}
#{JOIN_PREVIOUS_APPEALS}
order by BFD19
) APPEALS
"

# this query should not be used during distribution it is only intended for reporting usage
SELECT_READY_TO_DISTRIBUTE_APPEALS_ORDER_BY_BFD19_ADDITIONAL_COLS = "
select APPEALS.BFKEY, APPEALS.TINUM, APPEALS.BFD19, APPEALS.BFDLOOUT, APPEALS.AOD, APPEALS.BFCORLID,
CORRES.SNAMEF, CORRES.SNAMEL, CORRES.SSN,
STAFF.SNAMEF as VLJ_NAMEF, STAFF.SNAMEL as VLJ_NAMEL,
case when APPEALS.PREV_TYPE_ACTION = '7' then 1 else 0 end CAVC, APPEALS.PREV_TYPE_ACTION,
APPEALS.PREV_DECIDING_JUDGE
case when APPEALS.PREV_TYPE_ACTION = '7' then 1 else 0 end CAVC, PREV_TYPE_ACTION,
PREV_DECIDING_JUDGE
from (
select BFKEY, BRIEFF.TINUM, BFD19, BFDLOOUT, BFAC, BFCORKEY, AOD, BFCORLID,
VLJ_HEARINGS.VLJ,
PREV_APPEAL.PREV_TYPE_ACTION PREV_TYPE_ACTION,
PREV_APPEAL.PREV_DECIDING_JUDGE PREV_DECIDING_JUDGE
PREV_APPEAL.PREV_TYPE_ACTION PREV_TYPE_ACTION,
PREV_APPEAL.PREV_DECIDING_JUDGE PREV_DECIDING_JUDGE
from (
#{SELECT_READY_APPEALS_ADDITIONAL_COLS}
) BRIEFF
Expand All @@ -188,6 +209,7 @@ class VACOLS::AojCaseDocket < VACOLS::CaseDocket # rubocop:disable Metrics/Class
left join STAFF on APPEALS.VLJ = STAFF.SATTYID
order by BFD19
"

# rubocop:disable Metrics/MethodLength
def self.counts_by_priority_and_readiness
query = <<-SQL
Expand Down Expand Up @@ -413,7 +435,7 @@ def self.priority_ready_appeal_vacols_ids

def self.ready_to_distribute_appeals
query = <<-SQL
#{SELECT_READY_TO_DISTRIBUTE_APPEALS_ORDER_BY_BFD19}
#{SELECT_READY_TO_DISTRIBUTE_APPEALS_ORDER_BY_BFD19_ADDITIONAL_COLS}
SQL

fmtd_query = sanitize_sql_array([query])
Expand Down Expand Up @@ -862,4 +884,25 @@ def self.non_priority_appeals_affinity_date_count(in_window)
end
appeals
end

def self.appeals_tied_to_non_ssc_avljs
query = <<-SQL
with non_ssc_avljs as (
#{VACOLS::Staff::NON_SSC_AVLJS}
)
#{SELECT_READY_TO_DISTRIBUTE_APPEALS_ORDER_BY_BFD19}
where APPEALS.VLJ in (select * from non_ssc_avljs)
and (
APPEALS.PREV_DECIDING_JUDGE is null or
(
APPEALS.PREV_DECIDING_JUDGE = APPEALS.VLJ
AND APPEALS.HEARING_DATE <= APPEALS.PREV_BFDDEC
)
)
order by BFD19
SQL

fmtd_query = sanitize_sql_array([query])
connection.exec_query(fmtd_query).to_a
end
end
8 changes: 8 additions & 0 deletions app/repositories/aoj_appeal_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ def non_priority_appeals_affinity_date_count(in_window)
VACOLS::AojCaseDocket.non_priority_appeals_affinity_date_count(in_window)
end
end

def appeals_tied_to_non_ssc_avljs
MetricsService.record("VACOLS: appeals_tied_to_non_ssc_avljs",
name: "appeals_tied_to_non_ssc_avljs",
service: :vacols) do
VACOLS::AojCaseDocket.appeals_tied_to_non_ssc_avljs
end
end
end
# :nocov:
end
12 changes: 12 additions & 0 deletions spec/jobs/return_legacy_appeals_to_board_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@
end
end

context "aoj case docket is called" do
let!(:non_ssc_avlj_user_1) { create(:user, :non_ssc_avlj_user).vacols_staff }
let!(:legacy_aoj_appeal) { create(:legacy_aoj_appeal, judge: non_ssc_avlj_user_1) }

before { Seeds::CaseDistributionLevers.new.seed! }

it "runs eligible and moved appeals with AOJ Dockets" do
described_class.perform_now
expect(legacy_aoj_appeal.reload.bfcurloc).to eq("63")
end
end

describe "#non_ssc_avljs" do
let(:job) { described_class.new }

Expand Down
Loading