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

APPEALS-59239: Update of the national_hearing_queue_entries View Definition to Include Legacy Appeal Information #23335

Open
wants to merge 22 commits into
base: feature/APPEALS-57706
Choose a base branch
from

Conversation

ThorntonMatthew
Copy link
Contributor

Resolves Update of the national_hearing_queue_entries View Definition to Include Legacy Appeal Information

Description

Value Statement: As a Member of the Hearing Division, I need Legacy Appeals that require hearings to appear in the National Hearing Queue to schedule the hearing requisites.

Acceptance Criteria:

A new migration updates the materialized view to include Legacy Appeals by creating a UNION of the Legacy Appeals query with the AMA query.
The following columns for Legacy Appeals are included:
appeal_id (PKID of the record in the legacy_appeals table)
appeal_type (“LegacyAppeal”)
hearing_request_type (f_vacols_brieff.bfhr)
receipt_date (f_vacols_brieff.bfd19 - Must be in YYYYMMDD format)
external_id (vacols_id/f_vacols_brieff.bfkey)
appeal_stream (f_vacols_brieff.bfac - see mapping - store full name)
docket_number (f_vacols_folder.tinum)
The Legacy Appeals included in the subquery are limited to only those associated with open ScheduleHearingTasks.
Ensure that Appeals are only represented once even if they somehow have multiple open ScheduleHearingTasks in their task trees.

Acceptance Criteria

  • Code compiles correctly

Testing Plan

  1. Go to Jira Issue/Test Plan Link or list them below

@ThorntonMatthew ThorntonMatthew changed the base branch from main to feature/APPEALS-57706 October 23, 2024 18:07
Copy link

codeclimate bot commented Oct 23, 2024

Code Climate has analyzed commit e62a3f6 and detected 0 issues on this pull request.

View more on Code Climate.

@noahhansen-gov noahhansen-gov changed the title noahAndMattT/APPEALS-59239 - Update of the national_hearing_queue_entries View Definition to Include Legacy Appeal Information + CI Fixes APPEALS-59239: Update of the national_hearing_queue_entries View Definition to Include Legacy Appeal Information Oct 25, 2024
vacols_case: case3)

ScheduleHearingTask.find_by(appeal_id: legacy_appeal_completed.id, appeal_type: "LegacyAppeal")
.update(status: "completed")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is throwing a lint error.

context "when appeals have been staged" do
it "refreshes the view and returns the proper appeals", bypass_cleaner: true do
# refresh in case anything was run in rails console previously
NationalHearingQueueEntry.refresh
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be good to extract to a before(:each) block if this could be a concern for all tests in this file.

expect(NationalHearingQueueEntry.first.appeal_id).to eq 1
# first created legacy appeal is the only legacy appeal that should be in the db (id: 1)
expect(NationalHearingQueueEntry.second.appeal_id).to eq 1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests are flakey since sometimes nextval() (on the database side) or sequence_id (in FactoryBot) may not be 1 for the newly created records depending on what's going on elsewhere.

I think something like this work would:

  1. Save the appeal being created on line 14 to a variable
  2. Save the legacy appeal being created on line 25 to a variable
  3. Change lines 46 and 48 to this single line:
expect(
  NationalHearingQueueEntry.pluck(:appeal_id, :appeal_type)
).to match_array [
  [ama_with_sched_task.id, "Appeal"],
  [legacy_with_sched_task.id, "LegacyAppeal"]
]


# AMA
FactoryBot.create(:appeal, :with_schedule_hearing_tasks)
FactoryBot.create(:appeal)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a deal breaker, but wanted you aware in case you see it elsewhere:

config.include FactoryBot::Syntax::Methods

Because of the above like FactoryBot.create(:factory_name) can be executed as create(:factory_name) in tests (same goes goes build(:factory_name)).

ScheduleHearingTask.find_by(appeal_id: appeal_completed.id, appeal_type: "Appeal").update(status: "completed")

# LEGACY
case1 = FactoryBot.create(:case, bfkey: "700230001041", bfcorlid: "100000101011")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the staging of AMA and legacy appeals in this test:

Are you familiar with let and let! in RSpec? Utilizing these can make it so, if some of the appeals' setups were moved out of this individual example, they could be used in other ones too.

Since this is the only test in this file it's not a big deal, but I can see it being helpful in the future. "let! me know" if you'd like to address this in this story! I am fine either way.


# These are extensions that must be enabled in order to support this database
enable_extension "oracle_fdw"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can stay now that the test suite has been updated. :)

Comment on lines +8 to +11
CAST(appeals.receipt_date AS CHAR) AS receipt_date,
CAST(appeals.uuid AS CHAR) AS external_id,
CAST(appeals.stream_type AS CHAR) AS appeal_stream,
CAST(appeals.stream_docket_number AS CHAR) AS docket_number
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

      (appeals.receipt_date)::character(1) AS receipt_date,
      (appeals.uuid)::character(1) AS external_id,
      (appeals.stream_type)::character(1) AS appeal_stream,
      (appeals.stream_docket_number)::character(1) AS docket_number

The casting of these columns into CHAR types is defaulting to a size of 1. This is causing column values to be cut off.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The shown code is from schema.rb:

caseflow/db/schema.rb

Lines 2504 to 2507 in e01e74c

(appeals.receipt_date)::character(1) AS receipt_date,
(appeals.uuid)::character(1) AS external_id,
(appeals.stream_type)::character(1) AS appeal_stream,
(appeals.stream_docket_number)::character(1) AS docket_number

SELECT
legacy_appeals.id AS appeal_id,
'LegacyAppeal' AS appeal_type,
f_vacols_brieff.bfhr AS hearing_request_type,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just realized that the values for legacy and AMA hearings are recorded differently. I'll break that out into a separate story.

legacy_appeals.id AS appeal_id,
'LegacyAppeal' AS appeal_type,
f_vacols_brieff.bfhr AS hearing_request_type,
REPLACE(CAST(f_vacols_brieff.bfd19 AS CHAR), '-', '') AS receipt_date,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
REPLACE(CAST(f_vacols_brieff.bfd19 AS CHAR), '-', '') AS receipt_date,
REPLACE(CAST(f_vacols_brieff.bfd19 AS TEXT), '-', '') AS receipt_date,

This field is also being cut off.

@@ -3,5 +3,55 @@
require "rails_helper"

RSpec.describe NationalHearingQueueEntry, type: :model do
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing that some of the string processing/type casting in the SQL code caused some items to be truncated I think it'd be good to write some additional tests just to make sure things are being placed into the view with proper formatting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants