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

jcroteau/APPEALS-23894 - Close VeteranRecordRequest tasks for Veterans Readiness and Employment (VRE) business line #18948

Conversation

jcroteau
Copy link
Contributor

@jcroteau jcroteau commented Jul 6, 2023

Resolves https://jira.devops.va.gov/browse/APPEALS-23894

UAT PR: #18983

Description

From related SNOW ticket: APPEALS-4106 - Manually Complete VeteranRecordRequest INC22451913:

Caseflow is automatically creating VeteranRecordRequest tasks for the business line VRE. This is incorrect as VRE now uses VBMS and we don't need to get the records manually. There are currently 136 active VRE record request tasks that should be set to completed or cancelled. The tasks can be found in the database with the query SELECT * from tasks WHERE type='VeteranRecordRequest' AND status in ('assigned', 'on_hold', 'in_progress') AND assigned_to_id=220;

  • Note: As of this writing, the root cause of these errant tasks being created has not yet been addressed in the application code. See related Slack thread.

As a tier 4 developer I need to research and document the manual remediation steps to cancel all open Veteran Record Requests assigned to the Vocational Readiness and Education business line and its users so that Appeals can no longer be blocked by these tasks.

Acceptance Criteria

  • Remediation steps are identified and documented to
    • Find all open (IN_PROGRESS, ON_HOLD, ASSIGNED) Veteran Record Requests tasks assigned to
      • The Vocational Readiness and Education business (id 220 in prod)
      • Users belonging to the Vocational Readiness and Education org
    • Add logging to report metrics
      • How many tasks are we attempting close
      • How many were closed at the end of the script
      • How long each one took
      • List of tasks and errors
    • Loop through all open tasks identified and set status to cancelled
  • Introduces rake task remediations:cancel_vrr_tasks_open_for_vre, which identifies any currently open VeteranRecordReqeust Tasks that are assigned to the "Veteran Readiness and Employment" BusinessLine and cancels them and their open descendant tasks.

Testing Plan

Jira Test Issue: https://jira.devops.va.gov/browse/APPEALS-25089

Setup

  • Access the Rails console:
sudo su - 
source /opt/caseflow-certification/caseflow-certification_env.sh
cd /opt/caseflow-certification/src
bin/rails console
  • In the Rails console, find some test Veterans and note their file_number s
file_number_1, file_number_2 = Veteran.order(created_at: :asc).last(2).map(&:file_number)

Find initial count of open and cancelled VRR tasks for VRE

  • From the Rails console, run the following query and note the results:
vre_business_line =  
  BusinessLine.where(name: Constants::BENEFIT_TYPES["voc_rehab"]);
  
initial_count_of_open_vrr_tasks = 
  VeteranRecordRequest.open.where(assigned_to: vre_business_line).count

initial_count_of_cancelled_vrr_tasks = 
  VeteranRecordRequest.cancelled.where(assigned_to: vre_business_line).count

Create new VRR tasks for VRE

Establish Appeals w/ issues of Benefit type "Veterans Readiness and Employment" to create new VRR tasks for VRE:

  • Switch to a user w/ permissions to intake appeals (BVAISHAW in dev)

Establish Appeal for test Veteran 1

  • Visit /intake page
  • Select Decision Review Request: Board Appeal (Notice of Disagreement) — VA Form 10182
  • Enter Veteran's file_number (noted above)
  • Fill out and submit Review form:
    • What is the Receipt Date of this form? Yesterday
    • Was this form submitted through VA.gov? No
    • Which review option did the Veteran request? Direct Review
    • Is the claimant someone other than the Veteran? No
    • Did the Veteran check the "OPT-IN from SOC/SSOC" box on the form? N/A
  • Add an issue w/ Benefit type Veteran Readiness and Employment
    • Benefit type Veterans Readiness and Employment
    • Issue category Additional Training
    • Decision date Yesterday
    • Issue description foobar
  • Add an issue w/ Benefit type Education
    • Benefit type Education
    • Issue category Accrued
    • Decision date Yesterday
    • Issue description foobar
  • Click Establish appeal
  • Confirm that you get an Intake completed confirmation
  • From the Rails console, confirm that a VeteranRecordRequest task was created for the appeal and assigned to the VRE business line:
appeal_1 = Appeal.where(veteran_file_number: file_number_1).order(:created_at).last;
appeal_1.uuid
appeal_1.request_issues.first.benefit_type # => "voc_rehab"
vrr_task_1 = VeteranRecordRequest.where(appeal: appeal).first
vrr_task_1.assigned_to.name # => "Veterans Readiness and Employment"
  • Note the appeal uuid

Establish Appeal for test Veteran 2

  • Repeat the Intake steps above for the second test Veteran
    line:
appeal_2 = Appeal.where(veteran_file_number: file_number_2).order(:created_at).last;
appeal_2.uuid
appeal_2.request_issues.first.benefit_type # => "voc_rehab"
vrr_task_2 = VeteranRecordRequest.where(appeal: appeal).first
vrr_task_2.assigned_to.name # => "Veterans Readiness and Employment"

Find updated count of existing, open VRR tasks for VRE

  • From the Rails console, run the following query and note the result:
vre_business_line =  
  BusinessLine.where(name: Constants::BENEFIT_TYPES["voc_rehab"])

updated_count_of_open_vrr_tasks =
  VeteranRecordRequest.open.where(assigned_to: vre_business_line).count
  • The count should now be 2 more than the initial count (initial_count_of_open_vrr_tasks).
updated_count_of_open_vrr_tasks == (initial_count_of_open_vrr_tasks + 2)

#=> true

Run rake task to cancel existing open VRR tasks for VRE

  • cd into the Caseflow app root directory:
    • Local dev: cd /dev/appeals/caseflow
    • UAT: cd /opt/caseflow-certification/src
  • Run rake task:
bin/rake remediations:cancel_vrr_tasks_open_for_vre

Find final count of existing open and cancelled VRR tasks for VRE

  • From the Rails console, run the following query and note the result:
vre_business_line =  
  BusinessLine.where(name: Constants::BENEFIT_TYPES["voc_rehab"])
  
final_count_of_open_vrr_tasks = 
  VeteranRecordRequest.open.where(assigned_to: vre_business_line).count

final_count_of_cancelled_vrr_tasks = 
  VeteranRecordRequest.cancelled.where(assigned_to: vre_business_line).count
  • The final count of open VRR tasks for VRE should now be 0, and the final count of cancelled VRR tasks for VRE should be 2 more than the initial count:
final_count_of_open_vrr_tasks == 0

# => true

final_count_of_cancelled_vrr_tasks == (initial_count_of_cancelled_vrr_tasks + 2)

# => true

  • For feature branches merging into master: Was this deployed to UAT?

Best practices

Code Documentation Updates

  • Add or update code comments at the top of the class, module, and/or component.

Tests

Test Coverage

Did you include any test coverage for your code? Check below:

  • RSpec
  • Jest
  • Other

Code Climate

Your code does not add any new code climate offenses? If so why?

  • No new code climate issues added

Monitoring, Logging, Auditing, Error, and Exception Handling Checklist

Monitoring

N/A

Logging

  • Are logs being produced at appropriate log levels (debug, info, warn, error, fatal)?
  • Are logs structured (e.g., using log tags) for easier querying and analysis?
  • Are sensitive data (e.g., passwords, tokens) redacted or omitted from logs?
  • Is log retention and rotation configured correctly?
  • Are logs being forwarded to a centralized logging system if needed?

Auditing

  • Are user actions being logged for audit purposes?
  • Are changes to critical data being tracked ?
  • Are logs being securely stored and protected from tampering or exposing protected data?

Error Handling

  • Are errors being caught and handled gracefully?
  • Are appropriate error messages being displayed to users?
  • Are critical errors being reported to an error tracking system (e.g., Sentry, ELK)?
  • Are unhandled exceptions being caught at the application level ?

Exception Handling

  • Are custom exceptions defined and used where appropriate?
  • Is exception handling consistent throughout the codebase?
  • Are exceptions logged with relevant context and stack trace information?
  • Are exceptions being grouped and categorized for easier analysis and resolution?

@codeclimate
Copy link

codeclimate bot commented Jul 6, 2023

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

View more on Code Climate.

Comment on lines +9 to +11
CancelTasksAndDescendants.call(
VeteranRecordRequestsOpenForVREQuery.call
)

This comment was marked as resolved.

Comment on lines +24 to +31
def call
RequestStore[:current_user] = User.system_user

with_paper_trail_options do
log_time_elapsed { log_task_count_before_and_after { cancel_tasks } }
print_logs_to_stdout
end
end

This comment was marked as resolved.

This comment was marked as resolved.

@jcroteau jcroteau marked this pull request as ready for review July 7, 2023 00:46
lib/helpers/cancel_tasks_and_descendants.rb Show resolved Hide resolved
Comment on lines +24 to +31
def call
RequestStore[:current_user] = User.system_user

with_paper_trail_options do
log_time_elapsed { log_task_count_before_and_after { cancel_tasks } }
print_logs_to_stdout
end
end

This comment was marked as resolved.

lib/helpers/cancel_tasks_and_descendants.rb Show resolved Hide resolved
@raymond-hughes raymond-hughes merged commit 22c427f into master Jul 17, 2023
11 of 14 checks passed
@raymond-hughes raymond-hughes deleted the jcroteau/APPEALS-23894-close-vrr-tasks-for-vre-business-line branch July 17, 2023 20:21
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.

2 participants