Skip to content

Commit

Permalink
APPEALS-23420 fix missing hearing request type
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanpmessner committed Oct 1, 2024
1 parent fa728c4 commit 0ea89ea
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 23 deletions.
12 changes: 12 additions & 0 deletions app/services/search_query_service/appeal_row.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def search_response
attr_reader :query_row

# rubocop:disable Metrics/MethodLength
# rubocop:disable Metrics/AbcSize
def attributes
SearchQueryService::Attributes.new(
aod: aod,
Expand All @@ -42,6 +43,8 @@ def attributes
overtime: query_row["overtime"],
pact: pact_status,
paper_case: false,
readable_hearing_request_type: readable_hearing_request_type,
readable_original_hearing_request_type: readable_original_hearing_request_type,
status: queried_appeal.status,
type: stream_type,
veteran_appellant_deceased: veteran_appellant_deceased,
Expand All @@ -50,6 +53,7 @@ def attributes
withdrawn: withdrawn
)
end
# rubocop:enable Metrics/AbcSize
# rubocop:enable Metrics/MethodLength

def aod
Expand Down Expand Up @@ -151,6 +155,14 @@ def mst_status
end
end

def readable_original_hearing_request_type
queried_appeal.readable_original_hearing_request_type
end

def readable_hearing_request_type
queried_appeal.readable_current_hearing_request_type
end

def queried_appeal
@queried_appeal ||= begin
appeal_attrs, = JSON.parse query_row["appeal"]
Expand Down
2 changes: 2 additions & 0 deletions app/services/search_query_service/attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
:overtime,
:pact,
:paper_case,
:readable_hearing_request_type,
:readable_original_hearing_request_type,
:status,
:type,
:veteran_appellant_deceased,
Expand Down
10 changes: 10 additions & 0 deletions app/services/search_query_service/legacy_appeal_row.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def attributes
overtime: search_row["overtime"],
pact: pact,
paper_case: paper_case,
readable_hearing_request_type: readable_hearing_request_type,
readable_original_hearing_request_type: readable_original_hearing_request_type,
status: status,
type: stream_type,
veteran_appellant_deceased: veteran_appellant_deceased,
Expand Down Expand Up @@ -155,6 +157,14 @@ def decision_date
AppealRepository.normalize_vacols_date(vacols_row["bfddec"])
end

def readable_original_hearing_request_type
legacy_appeal.readable_original_hearing_request_type
end

def readable_hearing_request_type
legacy_appeal.readable_current_hearing_request_type
end

def legacy_appeal
@legacy_appeal ||= begin
appeal_attrs, = JSON.parse search_row["appeal"]
Expand Down
2 changes: 2 additions & 0 deletions app/services/search_query_service/legacy_attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
:overtime,
:pact,
:paper_case,
:readable_hearing_request_type,
:readable_original_hearing_request_type,
:status,
:type,
:veteran_appellant_deceased,
Expand Down
39 changes: 26 additions & 13 deletions app/services/search_query_service/queried_hearing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ def judge

def hearing_views
@hearing_views ||=
views_attributes.map do |view_attrs|
HearingView.new.tap do |v|
v.assign_attributes view_attrs
if views_attributes.present?
views_attributes.map do |view_attrs|
HearingView.new.tap do |v|
v.assign_attributes view_attrs
end
end
else
[]
end
end

Expand All @@ -32,20 +36,26 @@ def readable_request_type
end

def hearing_day
@hearing_day ||= HearingDay.new.tap do |hd|
hd.assign_attributes hearing_day_attributes
end
@hearing_day ||=
if hearing_day_attributes.present?
HearingDay.new.tap do |hd|
hd.assign_attributes hearing_day_attributes
end
end
end

def updated_by
@updated_by ||= User.new.tap do |u|
u.assign_attributes updated_by_attributes
end
@updated_by ||=
if updated_by_attributes.present?
User.new.tap do |u|
u.assign_attributes updated_by_attributes
end
end
end

def virtual?
%w(pending active closed).include?(
virtual_hearing.status
virtual_hearing&.status
)
end

Expand All @@ -69,9 +79,12 @@ def regional_office_timezone
end

def virtual_hearing
@virtual_hearing ||= VirtualHearing.new.tap do |vh|
vh.assign_attributes virtual_hearing_attributes
end
@virtual_hearing ||=
if virtual_hearing_attributes.present?
VirtualHearing.new.tap do |vh|
vh.assign_attributes virtual_hearing_attributes
end
end
end

def hearing
Expand Down
33 changes: 23 additions & 10 deletions spec/services/search_query_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@
let(:appeal_attributes) do
{
aod_based_on_age: false,
changed_hearing_request_type: "V",
original_hearing_request_type: "central",
stream_docket_number: docket_number,
veteran_file_number: ssn,
veteran: veteran,
stream_type: Constants.AMA_STREAM_TYPES.original,
uuid: uuid
uuid: uuid,
veteran: veteran,
veteran_file_number: ssn
}
end

Expand All @@ -70,13 +72,6 @@
mst_status: true,
pact_status: true
)
create(
:virtual_hearing,
hearing: appeal.hearings.first
)
appeal.hearings.first.update(updated_by: judge)
appeal.hearings.first.hearing_day.update(regional_office: "RO19")
appeal.hearings.first.hearing_views.create(user_id: judge.id)
# create work mode
appeal.overtime = true
AdvanceOnDocketMotion.create(
Expand All @@ -90,6 +85,14 @@
subject { SearchQueryService.new(docket_number: appeal.stream_docket_number) }

it "finds by docket number" do
create(
:virtual_hearing,
hearing: appeal.hearings.first
)
appeal.hearings.first.update(updated_by: judge)
appeal.hearings.first.hearing_day.update(regional_office: "RO19")
appeal.hearings.first.hearing_views.create(user_id: judge.id)

expect(appeal).to be_persisted

search_results = subject.search_by_docket_number
Expand Down Expand Up @@ -117,13 +120,23 @@
expect(attributes.mst).to eq appeal.decision_issues.any?(&:mst_status)
expect(attributes.pact).to eq appeal.decision_issues.any?(&:pact_status)
expect(attributes.paper_case).to be_falsy
expect(attributes.readable_hearing_request_type).to eq("Video")
expect(attributes.readable_original_hearing_request_type).to eq("Central")
expect(attributes.status).to eq Appeal.find(appeal.id).status.status
expect(attributes.veteran_appellant_deceased).to be_falsy
expect(attributes.veteran_file_number).to eq ssn
expect(attributes.veteran_full_name).to eq veteran_full_name
expect(attributes.contested_claim).to be_falsy
expect(attributes.withdrawn).to eq(false)
end

it "finds by docket number with not all hearing values" do
expect(appeal).to be_persisted

search_results = subject.search_by_docket_number

expect(search_results.length).to eq(1)
end
end

context "finds by file number" do
Expand Down

0 comments on commit 0ea89ea

Please sign in to comment.