Skip to content

Commit

Permalink
Feature/APPEALS-50887 (#22844)
Browse files Browse the repository at this point in the history
* Calvin/APPEALS-43852-cavc-levers (#21441)

* enabled cavc affinity levers in UI

* updated rspec

* [APPEALS-43849]Update CAVC Affinity Implementation for AMA Dockets to… (#21456)

* [APPEALS-43849]Update CAVC Affinity Implementation for AMA Dockets to Account for Omit/Infinity

* Affinity rules applied to non genpop

* Addressed comments

* Addressed comments

* fixed rubocop issues + added clarity to where clause

---------

Co-authored-by: Calvin <Calvin.Costa@va.gov>

* APPEALS-44956: Add AppealAffinity model and database table (#21526)

* add migration for appeal_affinities

* add AppealAffinity model and associations, update migration for new column

* update index to be unique

* add factory, add tests

* add factory traits to appeal and case for appeal affinities

* add combination trait to appeal factory

* add appeal_affinity to skipped associations in ETL reporting

* add a validation, test

* Craig/appeals 44958 (#21564)

* add new job, update affinity model validation and after save hook

* add update from push job

* fix job extending distribution scopes

* add with appeal affinities to distribution scopes

* typo

* add error handling, add test file

* add distributed case factory, refactor naming in job

* fix factories, added tests

* fix migration for null affinity start date column

* fixes, added tests

* more test updates

* add return in job if no query results, tests for no query results

* add test for after_save hook adding dist task instructions

* set start dist job to queue affinity job after running

* fix update job and start dist job spec

* queue affinity update job from push job

* code clarity

* fix judge in seed file

* remove comment, fix hearing factory, disable some seeds for testing

* add more tests

* test refactor

* update appeals for dist query to add affinity start, add seed file, fix hearing factory, add stat to dist factory

* disable new seed on reset

* update seed file with vet names, add another seed category

* fix distirbuted case factory?

* actually fix GHA runs

* lint, test fixes

* change constants in new job

* [Appeals 43850] Update Legacy Docket Queries to Account for the Previous Decision Judge and Type Action  (#21556)

* test changes for seans ticket

* test changes

* added joins to all required methods

* fixed lint

* fixed column ambiguity errors

* cleaned up naming scheme

* Documentation for JOIN_PREVIOUS_APPEALS constant

---------

Co-authored-by: Calvin <Calvin.Costa@va.gov>

* APPEALS-44959: Modify affinity date checks to use appeal_affinity (#21611)

* swap distribution queries from distribution_task to appeal_affinities

* update seed files to use appeal affinities instead of distribution task

* clean up seed file method names

* add missing Timecop.return in ama affinity case seed

* fix name of a method in a seed file

* remove references to distribution task in distribution scopes

* fix push priority job tests

* fix naming of args in one of the seed files

* fix user seed, fix date format in distribution task instructions

* fix tests for date format update

* APPEALS-44187: Factory Bot Additions (#21438)

* AC1: values for bfddec and bfmpro

* AC2: case issues updated to '3'

* AC3-4: attorney and judge additions

* ac 5: bfdpdcn addition

* AC6: case type action addition

* ac7: new folder match to original

* ac8: case issues set to original

* AC 3/4: added associations to original

* ac3/4: updated logic to handle no args

* ac3/4: return sattyid

* ac7:updating folder assignment

* ac7: added bfkey to except block

* ac7/8: update to case issue list and validations dismissed

* removed byebug

* ac7: added 'ticknum' to except

* lint fixes

* lint fixes

* lint fixes

* lint fixes

* nested trait into form_9 factory

* new addtions

* added .save to case issues

* resolving correspondent and titrnum associations

* fixed bfdc typo

* factory additions

* added ssn to associated corr.

* removed transient and added .save

* added after create to corr factory

* veteran lookup check prior to create

* committing missed 'end'

* moved over veteran create to case fact.

* move corr. association field to case fact.

* lint issues + corres. save

* Calvin/APPEALS-44957-rake-affinity (#21577)

* grabbed receipt dates from distributed cases

* refactored for functionality + added method to grab appeals that match

* using receipt date, get all related appeals

* added update/creation plus cleaned prior imple.

* gets most recent distributed case receipt_date

* skips if receipt_date is nil for performance

* if appeal affinity is nil, it will now be updated

* created spec file

* fixed non ready appeals

* updated query to match new AC

* removing comment

* testing for each docket

* updated spec file

* added new tests to rspec

* updated start date to receipt date instead of Time.now

* fixed date/time rspec errors

* added rails logger to know when rake task has finished

* added tag for rails log

* removed nonpriority dockets for direct_review and evidence_submission

* fixed lint issue

* fixed flaky spec test

* limits distributed cases query to within the last week

* APPEALS-46016: Add Affinity Start Date to the Explain Page (#21660)

* add affinity start date to explain page

* add feature test to verify dates display

* Sudhir/appeals 43851 (#21613)

* Implement CAVC + AOD Affinity Lever for AMA Dockets

* addressed comments

* addressed comments

* Addressed comments

* added cavc_aod_affinity in case distribution lever model

* addressed comments

* addressed comments

* updated specs

* Updated specs

* specs changes reverted

* ama_aod and ama_non_aod queries updated

* change the assertion in docket spec

* Craig/appeals 46196 (#21689)

* fix query, tested locally

* add basic test to verify csv downloads aren't broken

* APPEALS-43851: Add test to validate CAVC+AOD behavior on hearing docket appeals affinities (#21678)

* add test to validate cavc+aod on hearing docket appeals

* lint, test case_docket_spec fix

* modify case_docket_spec again

* more test fix testing

* attempt to fix test again

* test removing prev appeals from nonpriority queries

* more test tests

* feature toggle change in test

* reorder new portions of query

* remove unused portions of queries in case_docket

* revert unneeded change to query order

* revert unneeded change to query order

* update rake task and spec (#21731)

* APPEALS-46325: Add Seeds for AOD Appeals and Update Dates to Match CAVC (#21730)

* add aod hearing cases to ama affinity cases seed

* fix lever spec

* APPEALS-45148: Hook to clear saved affinity date (#21623)

* initial imp. idea

* AC1: check for affinity_start_date on assignment

* AC2/3: update affinity start date  w/ instr.

* updates to naming, instructions, and hook logic

* updates after review

* rspec coverage and addtional condition

* removed unused identifier

* removed reduntant 'self's

* added update on actual AA record

* updated to save aa record and addtional rspec

* added change to assignment on no record test

* check for assignment

* addd update to 'on_hold' status

* public method to handle legacy affinity appeals

* added .reload to :with_affinity_appeal

* added .reload to :ready_for_distribution

* updates to pass explain_spec

* switched boolean values

* typo

* readujsted order on :create for affinity appeal

* removed after(:create)

* testing rspec by readding after :create

* reloading in assertation

* addressing lint errors

* fix seeds/users_spec

* add case dist lever to new tests (#21776)

* fix tests, add lever to factory, fix dist scopes (#21779)

* fix rubocop warning

* Acd/appeals 43853 43854 (#21971)

* Calvin/appeals 43853 (#21723)

* initial updates

* removing unnecessary variable

* focused in on priority

* removing non priority stuff

* added general comments

* added BFAC and AOD to cavc aod lever query

* adding judge vacols id to query

* aod affinity_start_date filter initial changes

* fixed sorting

* fixed rubocop issues

* updated filter method

* error handling

* added ineligibility to queries for PREV_DECIDING_JUDGE

* fixed SQL query + added comments

* added exclude from affinity check into the case docket queries

* error handling + fixing sql queries

* rejects appeals without affinity_start_dates and nonmatching judges

* fixing rubocop offenses

* fixed inconsistencies between methods

* fixed conditions for rejecting appeals

* refactored cavc aod affinity filter to make it much easier to read

* refactored code to account for AC6

* error handling for empty exclude from affinity

* reverted next if block to old logic to ensure it works

* added PREV_DEC_JUDGE is not null

* case.rb factory changes

* added more options to legacy_cavc_appeal creation

* cleaned up code for simpler reading

* fix for aod legacy cavc creation

* added tied to option to legacy cavc appeal factory

* limits are now handled correctly in query

* replaced return false to next if, as return false was causing unexpected behavior

* fix rspecs + one edge case

* added cavc aod lever creation to rspecs

* removed bfac and aod from nonpriority query

* cavc aod appeals w/excluded judges are now properly being filtered

* refactored excluded judges check

* added to old query to fix rspec errors

* modified case factory bot

* query now handles when prev_deciding_judge is nil

* removed unnecessary condition

* fixed case factory to now have tied_to attatched to orig appeal

* fixed next if block within filter

* handles omit scenarios + correctly rejects with next

* working on rspec (still failing)

* fix for ineligble VLJ when infinite

* fixed rspec suite for cavc aod filters

* fixed omit scenario in cavc aod affinity filter

* consolidation & readability refactor

* rubocop fixes

* fixed spec error

* Implement CAVC Affinity for Legacy Docket (#21706)

* Implement CAVC Affinity for Legacy Docket

* addressed comments

* Added BFAC in the query

* code changes for affinitty date

* Added affinity code

* code refactor and removed non priority code changes

* fixed syntax change

* Addressed comments

* refactor cavc affinity filter

* refactored code

* code refactor

* code refactor

* Updated existing specs

* code refactor

* Added new rspecs

* code refactor and added test  cases

* code refactor

* added test cases

* fixes push_priority_spec

* fixed rubocop issues

* rubocop issue fixed

* refactored code to make it easier to understand

* refactored + fixed rspec and lint errors

---------

Co-authored-by: Calvin <Calvin.Costa@va.gov>
Co-authored-by: calvincostaBAH <108481161+calvincostaBAH@users.noreply.github.com>

* basic creation of legacy affinity cases seed data

* bug fixes, added bfcorlid with veterans, fully runs now

* added new appeals for affinity_and_tied_to_judge

* made data have realistic bfcorlids

* changes document sequence to use less digits

* added new file numbers for tied_to cases to make them easier to identify

---------

Co-authored-by: samasudhirreddy <108430298+samasudhirreddy@users.noreply.github.com>

* APPEALS-50692: Update Appeals Ready to Distribute CSV to include CAVC remand original judge (#22070)

* CSV download functional

* add tests, fix CSV query in CaseDocket

* fix lint

* Remove transaction_wrapper

* Remove extra newline

* Calvin/appeals 44313 (#22119)

* initial seed data file

* added legacy cavc and cavc aod affinity cases

* update

* fixed tied to for legacy appeals

* added AOD versions of appeals

* small lint fixes

* ensured AOD cases for legacy hearings with exluded or ineligible judge

* added vacols staff record creation for users without it

* APPEALS-51045: Remove ReceiveNotificationJob (#22207)

Co-authored-by: nhansen3 <noah.hansen1323@gmail.com>

* MattT/APPEALS-51115: Initialize FIFO SQS Queues Locally (#22182)

* Set local env to utilize FIFO queues where appropriate

FIFO queues are configured with the same attributes as our queues in higher environments.

* Resolve failing test

* Remove defunct test

* Update make commands

---------

Co-authored-by: Matthew Thornton <ThorntonMatthew@users.noreply.github.com>

* APPEALS-47741: Update the UpdateAppealAffinityDatesJob to add appeal_affinity records for Legacy Appeals (#22023)

* AC1: changes and respective tests

* adjustements after refactoring

* identifier mismatch

* name update

* name update

* added appeal affinity filter

* updated comment

* remove byebug

* update rspec to handle hash input

* added no start date test case

* updated process method test

* removed 'todo' comment

* dried up query string

* aligned conditions

* update to hash quotations

* update to hash quotations

* added legacy to priority receipt dates from dist.

* moved append to resulting list

* added legacy receipt date to push job hash

* uncomment call to legacy

* updated dist.id to @dist_id

* uncomment call to process legacy appeals

* handling update to legacy docket type

* current rspec status

* fixed typo

* fix rspec

* legacy spec additions

* legacy spec additions

* added legacy dist. case factory

* removed vacols_judge ref

* updates for spec

* final review

* removed comment

* rubocop fixes

* fix rubocop warnings (#22225)

* APPEALS-51847: Institute Database Migration for Establishing 'sms_status_reason' and 'email_status_reason' Columns (#22208)

* adding and running migration

* adding comments to migration and re running db:migrate

* pushing up original scheam

* committing schema

* small edit to migration and deleting unnecessary columns from schema

---------

Co-authored-by: nhansen3 <noah.hansen1323@gmail.com>
Co-authored-by: Matthew Thornton <99351305+ThorntonMatthew@users.noreply.github.com>

* Fix rubocop and tests (#22231)

* removing job and all mentions of job (#22212)

Co-authored-by: nhansen3 <noah.hansen1323@gmail.com>
Co-authored-by: Matthew Thornton <99351305+ThorntonMatthew@users.noreply.github.com>

* MattT/APPEALS-51059: Alter Select Quarterly Statuses (#22239)

* Alter status messages

* Save more info in fake response

* Swap keys

* Add missing param

* Test fixes. Also, setting appeal_docketed to false whenever appeals are decided or cancelled

* Fix fasterer issue

---------

Co-authored-by: Matthew Thornton <ThorntonMatthew@users.noreply.github.com>

* MattT/APPEALS-51101: Rewrite ProcessNotificationStatusUpdateJob to Consume Messages from an SQS Queue (#22247)

* Update fake response body

* Try enabling localstack in CI

* Init SqsService and alter most/all of the ProcessNotificationStatusUpdatesJob

* Create SQS queues in test env

* Change port formatting

* Mount docker socket

* Try localstack hostname

* Wait for localstack in CI

* Add more yarddoc comments

* Log errors and number of messages processed

* Add custom error classes

* Add yarddoc comments to SqsService class

* Create SqsService spec file

* Redo much of ProcessNotificationStatusUpdatesJob's spec file

* Disable line length checks for yarddoc comments

---------

Co-authored-by: Matthew Thornton <ThorntonMatthew@users.noreply.github.com>

* Calvin/appeals 52551 (#22293)

* age_of_n_oldest_priority_appeals_available_to_judge time out changes

* fixed timeout issue for distribute_priority_appeals

* fixed lint errors

* Craig/case docket optimization (#22294)

* age_of_n_oldest_priority_appeals_available_to_judge time out changes

* fixed timeout issue for distribute_priority_appeals

* optimize case docket priority distribution methods

* fix das deprecation distribution spec

---------

Co-authored-by: Calvin <Calvin.Costa@va.gov>

* APPEALS-51087: Rewrite Api::V1::VaNotifyController#notification_update Controller Action to No Longer Utilize Redis (#22295)

* initial push

* rubocop'n

* fixing tests?

* rubocop'n

* addressing most of matt's comments

* removing yard doc files and keeping comment

* rubocop

---------

Co-authored-by: nhansen3 <noah.hansen1323@gmail.com>

* Update admin_ui_spec.rb for CAVC levers being enabled

* Remove extra attribute

* Fix incorrect log counts

* Fix log statement

* Fix typo

* APPEALS-53603: Modify logic to always show recipient information if present (#22414)

* initial commit

* making rspec tests happy

* linting

* adding tests back and refactoring

* small char error

---------

Co-authored-by: nhansen3 <noah.hansen1323@gmail.com>

* Sync decided appeals with states table (#22434)

* APPEALS-52882 Sync decided appeals decision_mailed status

* APPEALS-52882 Fix lint issues

* APPEALS-52882 Fix codeclimate issues

* APPEALS-52882 Address PR feedback

* APPEALS-52882 Address PR feedback

* Jcohen/APPEALS-52861 (#22450)

* APPEALS-52861 Bug fix implemented.

* APPEALS-52861 cleaned up some code through aliasing a common method name between appeal_types, eliminating a check that we do in the AppealDecisionMailed module.

* APPEALS-52861 fixed method name error.

* APPEALS-52861 fixed some tests.

* APPEALS-52861 fixed More tests.

* APPEALS-52861 fixed More tests.

* APPEALS-52861 feature branch changes merged in with working branch and method name changes extracted.

* APPEALS-52861 feature branch changes merged in with working branch and method name changes extracted, included case statement.

* APPEALS-52861 moved case statement to another file to be the boolean check for constested status on an appeal.

---------

Co-authored-by: Jonathan Cohen <cohen_jonathan@bah.com>
Co-authored-by: Marc Steele <71673522+msteele96@users.noreply.github.com>

* APPEALS-52892: For all legacy appeal states/notifications check status in VACOLS (#22455)

* initial commit

* addressing comments

* small change

* making tests
happy

* fixing spec tests

* rubocop'n

* reverting

---------

Co-authored-by: nhansen3 <noah.hansen1323@gmail.com>
Co-authored-by: Marc Steele <71673522+msteele96@users.noreply.github.com>

* APPEALS-53993: Update Implementation of Legacy Appeals with Hearing Held (#22473)

* implement new hearing requirement and test

* first pass at seed data for testing

* add new case to test and seed, fix typo and comments

* update for new 8.2.1.1 requirement

* fix rubocop warning

* fix error in seed file

* add new affinity scenario to seed data

* make some seed methods private

* fix rubocop warnings

* APPEALS-55159: Parameter Requirements Are Too Stringent Given What We Will Expect from VA Notify (#22561)

* APPEALS-55159

* updating tests

* APPEALS-55159 Refactor permitted and required params

* APPEALS-55159 Fix linting issue

---------

Co-authored-by: nhansen3 <noah.hansen1323@gmail.com>
Co-authored-by: msteele <Marc.Steele@va.gov>
Co-authored-by: Marc Steele <71673522+msteele96@users.noreply.github.com>

* Adding rake task to sync decided appeals (#22492)

* APPEALS-52872 Add rake task to sync decided appeals

* APPEALS-52872 Remove byebug

* APPEALS-52872 Fixing lint errors

* APPEALS-52872 Addressing performance issues

* APPEALS-52872 Addressing performance issues

* APPEALS-52872 Fix ENV variable update

* APPEALS-52872 Parallelizing AppealState updates

* APPEALS-52872 Remove byebug

---------

Co-authored-by: Marc Steele <71673522+msteele96@users.noreply.github.com>

* Prevent Prodtest from contacting VA Notify Staging (#22629)

* APPEALS-54918 Update VA Notify fake service and initializer

* APPEALS-54918 Add CASEFLOW_BASE_URL env var in demo/dev

* APPEALS-54918 Add seed file for API Key and added to main seed execution

* APPEALS-54918 Add missing argument to method definition

* APPEALS-54918 Update "to" params and fix linting issues

* APPEALS-54918 Prevent post requests in test env

* Rename ApiKeys seed file

* Fix linting error on require statement

* Add argument for call within sync_review_job.rb and minor refactor

* Inherit seed from base, align with AMA for seed file placement

* added test cases for infinite and omit levers with desired outcomes

* add check for hearing date to levers being infinite

* fix lint

* feature/APPEALS-34124-43428-29105-28925-33581 - Rails 6.1 upgrade (release) (#22776)

* 🔧 Assume defaults for `config.action_dispatch.use_cookies_with_metadata` and `config.action_mailer.delivery_job`

The following config settings are not backwards compatible:

- config.action_dispatch.use_cookies_with_metadata
- config.action_mailer.delivery_job

Now that Rails 6.0 is stable on production, we can assume
their default values going forward.

* ✅ Fix flakey spec

* 🔧 Assume default for `config.action_dispatch.use_authenticated_cookie_encryption`

Since we are making other cookie configuration changes in this PR for Rails 6.0,
this is an opportune time to migrate this Rails 5.2 cookie setting to its
default value as well.

* ⏪️ Restore overrides for `config.action_dispatch.use_authenticated_cookie_encryption` and `config.action_dispatch.use_cookies_with_metadata`

While testing in PreProd, we discovered that, without these cookie config overrides,
re-authentication was broken -- after logging out, a user could not log back in.

Since the default settings are still optional going forward, we can restore these
overrides and devise a solution to migrate cookies later.

For more details, see Jira story APPEALS-54897:

https://jira.devops.va.gov/browse/APPEALS-54897

* ✨ Add new utility module for adding DB indexes concurrently

Introduces `Caseflow::Migrations::AddIndexConcurrently` as a replacement
for `Caseflow::Migration` for migrations on ActiveRecord 6.0 and beyond,
since `Caseflow::Migration` is forever coupled to ActiveRecord 5.1 due
to its extensive use on legacy migrations and should be deprecated moving
forward.

* 🗑️ Deprecate `Caseflow::Migration`

* 🔧 Add instructive error message for non-concurrent `add_index` migrations

* 🚨 Address linter / codeclimate complaints

* ✨ Introduce `SslRedirectExclusionPolicy`

To be used in the environment configuration settings for excluding exempt
request paths from SSL redirects when `config. force_ssl = true`

* ♻️ Replace deprecated controller-level `force_ssl`

Replace deprecated controller-level `force_ssl` with
equivalent configuration settings in preparation for
the Rails 6.1 upgrade.

* 🔥 Remove deprecated config setting `config.active_record.sqlite3.represent_boolean_as_integer`

This will have no implications for Caseflow, since we are only using the `sqlite3`
adapter nominally for the `demo_vacols` database, which is not actually being used
in our demo environments (demo environments are deployed as `development` envs).

* ⬆️ Update `caseflow-commons` to resolve sub-dependency conflicts

Removes unneeded gems `bourbon` and `neat`, which had a sub-dependency conflict on `thor`.

* ⬆️ Update rails and other gems as necessary

* 🐛 Fix 'uninitialized constant' error when loading app

* ⬆️ bin/rails app:update - Apply relevant changes

* 🔧 Override default for `config.active_record.has_many_inversing`

* 🔧 Assume default for `config.active_storage.track_variants`

We're not currently using ActiveStorage in Caseflow, so it
is safe to just assume the default here.

* 🔧 Override default for `config.active_job.retry_jitter`

The default jitter is probably safe, however, I'm not 100% sure that we
don't have any jobs that need to be requeued with exact wait times. So
we let's override this for now to stay on the safe side.

* 🔧 Assume default for `config.active_job.skip_after_callbacks_if_terminated`

We're not currently using `throw :abort` within any `before_enqueue`/`before_perform` 
callbacks on existing Caseflow jobs, so the default should be fine here.

For more background, see
https://lilyreile.medium.com/rails-6-1-new-framework-defaults-what-they-do-and-how-to-safely-uncomment-them-c546b70f0c5e#4c60

* 🔧 Assume default for `config.action_dispatch.cookies_same_site_protection`

This setting controls the `SameSite` optional attribute for the
`Set-Cookie` header.

`SameSite=Lax` means that the cookie is not sent on cross-site requests,
such as on requests to load images or frames, but is sent when a user is
navigating to the origin site from an external site (for example, when
following a link). This is the default behavior if the SameSite attribute
is not specified.

`Lax` is currently the default assumed by both Chrome and Edge browsers
when this attribute is left unspecified, so assuming this value
should be sensible. It allows us to have our cake (blocking CSRF attacks)
and eat it too (providing a logged-in experience when users navigate to
Caseflow  across origins).

For more background, see
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value
- https://lilyreile.medium.com/rails-6-1-new-framework-defaults-what-they-do-and-how-to-safely-uncomment-them-c546b70f0c5e#1f15

* 🔧 Assume default for `config.action_controller.urlsafe_csrf_tokens`

* 🔧 Assume default for `ActiveSupport.utc_to_local_returns_utc_offset_times`

We're not using `ActiveSupport::TimeZone.utc_to_local` anywhere,
so the default is safe to assume here.

* 🔧 Assume default for `config.action_dispatch.ssl_default_redirect_status`

The default is safe to assume.

For more background, see
https://lilyreile.medium.com/rails-6-1-new-framework-defaults-what-they-do-and-how-to-safely-uncomment-them-c546b70f0c5e#4c3e

* 🔧 Assume default for `config.active_record.legacy_connection_handling`

The default should be safe to assume here, as we do not do any
role or shard switching on database connections.

For more background, see
https://lilyreile.medium.com/rails-6-1-new-framework-defaults-what-they-do-and-how-to-safely-uncomment-them-c546b70f0c5e#8007

* 🔧 Assume default for `config.action_view.form_with_generates_remote_forms`

We don't use the `form_with` helper anywhere, so this behavior change is
inconsequential for us, and we can safely assume the new default.

* 🔧 Assume default for `config.active_storage.queues.analysis`

We do not use ActiveStorage, so the default is safe to assume here.

* 🔧 Assume default for `config.active_storage.queues.purge`

We do not use ActiveStorage, so the default is safe to assume here.

* 🔧 Assume default for `config.action_mailbox.queues.incineration`

We don't use ActionMailbox, so the new default is safe to assume here.

* 🔧 Assume default for `config.action_mailbox.queues.routing`

We do not use ActionMailbox, so the default is safe to assume here.

* 🔧 Assume default for `config.action_mailer.deliver_later_queue_name`

We're not using `ActionMailer::MessageDelivery #deliver_later` anywhere,
so the default is safe to assume.

* 🔧 Assume default for `config.action_view.preload_links_header`

This flag can be safely uncommented. Browsers that support Link
headers will get a performance boost. Browsers that don’t will
ignore them.

We override in `development` environments to avoid an edge case
leading to an HTTP response header overflow.

For more background, see
https://lilyreile.medium.com/rails-6-1-new-framework-defaults-what-they-do-and-how-to-safely-uncomment-them-c546b70f0c5e#3679

* 🔥 Remove 'new_framework_defaults_6_1.rb'

* 🔧 Load defaults for Rails 6.1

* ♻️ Extract constant

* ♻️ Migrate to new Rails deprecation config where applicable

* ♻️ Push members down now that there is only one subclass

* 🩹 Add forgotten disallowed deprecation warning

This deprecation warning was addressed by the following
PR, but we forgot to add it to the list of disallowed
deprecation warnings:

#21614

* 💡 Update comment

Task `rake routes` has been replaced with `rails routes`

* ✅ Update test to account for change to `ActionDispatch::Response#content_type` 

`ActionDispatch::Response#content_type` now returns the full Content-Type header

* 🚨 Exclude 'config.ru' from Rubocop cops

* 🚚 Move 'db/etl/migrate' to 'db/etl_migrate'

* 🚚 Move 'db/etl/schema.rb' to 'db/etl_schema.rb'

* ♻️ Arrange 'database.yml' configs by environment

Group DB configs by environment in anticipation of
reformatting for Rails 6+ multi-DB configuration.

* 🔧 Reformat 'database.yml' to Rails 6+ multi-DB conventions

* 🔧 Add etl migration paths to DB config

* 🔧 Update DB connection names in 'database_cleaner' config

* ♻️ Use new database-specific rake tasks

After migrating to the Rails 6+ native multi-database configuration,
the behavior of some DB management tasks, such as `rake db:migrate`
changed such that they now act on ALL databases and not just the
primary database. So we must replace the invocations of these
tasks with their new, database-specific counterparts.

* ➖ Remove 'multiverse' gem

Now that we have fiully transitioned to Rails-native
multi-database support, we are no longer reliant on
the 'multiverse' gem and can remove it.

* 🗃️ Prohibit execution of vacols DB and non-DB-specific rake tasks

After transitioning to Rails-native multi-DB support,
the behavior of some DB tasks changed such that they will now
act on ALL databases and not just the primary database
(ex. `rake db:migrate` will now migrate ALL databases).

To avoid accidents, we re-define these tasks here to no-op
and output a helpful message to redirect developers toward
using their new database-specific counterparts instead.

* ♻️ Create new environment for GH workflow 'Make-docs-to-webpage'

Instead of performing a bunch of hard-to-maintain `sed` gymnastics
to modify the existing 'test' environment, let's create a new
'make_docs' environment (based off of 'test') and configure it
appropriately for use by the 'Make-docs-to-webpage' GH workflow.

* 💚 Remove redundant DB migrations from CI workflow

Task `db:schema:load` already loads the checked in schema,
so there should be no need to run `db:migrate` afterwards.

* 🐛 Fix `spec/mailers/hearing_mailer_spec.rb` - `NoMethodError`

Addresses the following error:

  NoMethodError: undefined method `build_lookup_context' for ActionView::Base:Class

* 🐛 Fix `spec/workflows/post_decision_motion_updater_spec.rb` - `FrozenError`

Addresses the following error:

  FrozenError: can't modify frozen Hash: {}

* ✅ Add test for `RoSchedulePeriod`

* 🐛 Fix `spec/models/schedule_period_spec.rb` - `ActiveRecord::RecordInvalid`

Apparently, there were some changes to the inner workings of
`ActiveModel::Errors` in Rails 6.1, causing a model to be
considered invalid in the case that `errors[:base] == [[]]`.
This makes sense, as `[[]]` is not considered "empty".

Unfortunately, this was causing `RoSchedulePeriod #validate_spreadsheet`
to inadvertently mark the model as invalid upon creation.
`HearingSchedule::ValidateRoSpreadsheet #validate` returns an
empty array (`[]`) when valid, which gets pushes onto the
`RoSchedulePeriod` `errors[:base]` array, resulting in a
non-empty array (`[[]]`) and an erroneously invalid disposition.

Furthermore, calling `<<` to an `ActiveModel::Errors` message array
in order to add an error is a deprecated, so we can take this
opportunity to use the new `#add` API to hit two birds with one stone.

The change implemented here is not a pure refactoring, however the
end-user experience is unchanged in terms of how errors are presented
when attempting to upload a spreadsheet with multiple non-conformities.

Down the road, we may want to consider moving
`HearingSchedule::ValidateRoSpreadsheet` toward using
`ActiveModel::Validations` in order to leverage the
full `ActiveModel::Errors` API and construct the
errors object in the prescribed manner.

For more details see
- https://api.rubyonrails.org/v6.1.7.7/classes/ActiveModel/Validations.html
- https://api.rubyonrails.org/v6.1.7.7/classes/ActiveModel/Errors.html

* 🐛 Fix `spec/mailers/hearing_mailer_spec.rb` - `ActionView::Template::Error`

* ✅ Fix `spec/models/veteran_spec.rb`

* ✅ Fix `spec/sql/ama_cases_sql_spec.rb`

Addresses failures such as the below:

  0) AMA Cases Tableau data source expected report calculates age and AOD based on person.dob
     Failure/Error: expect(aod_case["aod_veteran.age"]).to eq("76")

       expected: "76"
            got: 0.76e2

* ✅ Fix multiple specs - `Minitest::UnexpectedError`

Test helper method `#perform_enqueued_jobs` now wraps exceptions
in an `Minitest::UnexpectedError`:

https://github.com/rails/rails/blob/914caca2d31bd753f47f9168f2a375921d9e91cc/activejob/lib/active_job/test_helper.rb#L591

So, to assert that a specific
exception is raised during execution of the `#perform_enqueued_jobs`
block, we must rescue the `Minitest::UnexpectedError` and make the
assertion on its error message instead.

* ✅ Fix `spec/lib/helpers/association_wrapper_spec.rb`

* ✅ Fix `spec/controllers/api/v1/jobs_controller_spec.rb`

In Rails 6.1, `ActiveJob #perform_now` was changed to
behave as it did once before (at the behest of GitHub),
returning the value fo the job instead of true/false.

See related GH issue: rails/rails#38040

* 🐛 Fix `spec/controllers/appeals_controller_spec.rb` - `NoMethodError`

Addresses error:

  NoMethodError: undefined method `workflow' for #<CaseSearchResultsForVeteranFileNumber:0x00007f9a030966c8>

  0) AppealsController GET appeals when current user is a System Admin when request header does not contain Veteran ID responds with an error
     Failure/Error: errors: errors.messages[:workflow],

     NoMethodError:
       undefined method `workflow' for #<CaseSearchResultsForVeteranFileNumber:0x00007f9a030966c8>
     # ./app/workflows/case_search_results_base.rb:31:in `search_call'

* 🐛 Fix `CaseSearchResultsBase` validations

Addresses test failures in `spec/controllers/appeals_controller_spec.rb`
similar to the below:

  AppealsController GET appeals when current user is a System Admin when request header does not contain Veteran ID responds with an error
     Failure/Error: expect(response_body["errors"][0]["title"]).to eq "Veteran file number missing"

       expected: "Veteran file number missing"
            got: nil

Using `ActiveModel::Errors` to store error data in an arbitrary format may have been
somewhat permissible in the past, but it is an abuse of the object's intended use and is
also proving incompatible with the more formalized `ActiveModels::Errors` API in Rails 6.1.

In order to preserve the existing response shape of the affected JSON endpoints,
we need to move away from the `ActiveModel::Validations` implementation on `CaseSearchResultsBase`
(and its descendent classes) to a more bespoke method of performing validations and aggregating
errors, since Rails 6.1 `ActiveModel::Errors` is no longer appropriate for  our needs here.

* ✅ Fix `spec/controllers/application_controller_spec.rb` -- Cache-Control error

Addresses the test failure below:

    ApplicationController no cache headers when toggle set sets Cache-Control etc
     Failure/Error: expect(response.headers["Cache-Control"]).to eq "no-cache, no-store"

       expected: "no-cache, no-store"
            got: "no-store"

       (compared using ==)
     # ./spec/controllers/application_controller_spec.rb:59:in `block (4 levels) in <top (required)>'

In Rails 6.1, the `no-store` directive is exclusive of any others
that are set on the `Cache-Control` header, which makes sense given
the specification https://datatracker.ietf.org/doc/html/rfc7234#section-3

This change was implemented in PR rails/rails#39461

Since it no longer makese sense to set both `no-store` and `no-cache` directives,
we will only set `no-store` here, as that is the stronger of the two.

* 🐛 Fix multiple specs - `ActiveRecord::EagerLoadPolymorphicError`

Addresses multiple test failures caused by the error below:

  QueueConfig.to_hash title when assigned to an org is formatted as expected
     Failure/Error:
       tasks.with_assignees.group("assignees.display_name").count(:all).each_pair.map do |option, count|
         label = self.class.format_option_label(option, count)
         self.class.filter_option_hash(option, label)
       end

     ActiveRecord::EagerLoadPolymorphicError:
       Cannot eagerly load the polymorphic association :appeal
     # ./app/models/queue_column.rb:110:in `assignee_options'

* 🐛 Fix `spec/models/task_spec.rb` - `update_all` clears query cache

In Rails 6.1.7.7, the method `ActiveRecord::Relation #update_all`
will now clear any records cached by the calling relation.

This was altering the behavior of `Task #cancel_task_and_child_subtasks`
and causing the following test failure:

  Task#cancel_task_and_child_subtasks cancels all tasks and child subtasks
     Failure/Error: expect(second_level_tasks[0].versions.count).to eq(initial_versions + 2)

       expected: 3
            got: 2

       (compared using ==)
     # ./spec/models/task_spec.rb:368:in `block (3 levels) in <top (required)>'

To remedy, we will now cache the necessary Task records in an Array, which can
be used for generating PaperTrail versions both before and after the `update_all`.

* 🐛 Fix `spec/services/hearings/calendar_service_spec.rb` - template rendering error

Addresses the following test failure:

  Hearings::CalendarService.confirmation_calendar_invite returns appropriate iCalendar event
     Failure/Error: expect(ical_event.description).to eq(expected_description)

       expected: "You're scheduled for a virtual hearing with a Veterans Law Judge of the Board of Veterans' Appeals.\...to reschedule or cancel your virtual hearing, contact us by email at bvahearingteamhotline@va.gov\n"
            got: #<Icalendar::Values::Text("You're scheduled for a virtual hearing with a Veterans Law Judge of the Bo... reschedule or cancel your virtual hearing, contact us by email at bvahearingteamhotline@va.gov\n")>

* 🐛 Fix YAML syntax error caused by whitespace in ENV var

Address the following error, found during demo deployment:

  rake aborted!
  Cannot load database configuration:
  YAML syntax error occurred while parsing /caseflow/config/database.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Error: (<unknown>): could not find expected ':' while scanning a simple key at line 49 column 5

* ⬆️ Update `caseflow-commons` dependency to latest ref

Removes `bourbon` and `neat` dependencies.

* APPEALS-57351 Inactive Appeal Errors present when outcoding an appeal (#22721)

* APPEALS-57351 add template name check to handle errors

* APPEALS-57351 Add template_name argument to spec tests

* Update app/models/prepend/va_notify/appellant_notification.rb

Co-authored-by: Matthew Thornton <99351305+ThorntonMatthew@users.noreply.github.com>

* APPEALS-57351 Partial rspec updates, pushed before handing off

* APPEALS-57351 Add specs requested during review

* Update spec/controllers/idt/api/v2/appeals_controller_spec.rb

---------

Co-authored-by: Matthew Thornton <99351305+ThorntonMatthew@users.noreply.github.com>

* feature/APPEALS-50882 - Open Telemetry configuration and implementation (#22787)

* feature/appeals-45972 (#21950)

* Remove UUID from attrs sent_to metrics. (#21630)

* Remove UUID from attrs sent_to metrics.

* pushing with some linting issues for visibility.

* Change config implementation.

* Remove UUID from spec

* remove uuid from update_appellant job

* diable rubocop for open_telemetry init

* OTEL fixes

* rescue, errors

---------

Co-authored-by: mikefinneran <110622959+mikefinneran@users.noreply.github.com>

* add otel reqs

* Remove throw

* comment out otel file loop

* try vendor suggested config

* update otel config to match vendor

* update pg gem

* otel include dt_host file

* otel require bundler and rubygems

* otel subset of instrumentation

* Revert "update pg gem"

This reverts commit fc1a45d.

* update redis and minimize otel instrumentation to just rails, rack, and activerecord

* otel add use_all except pg and redis

* otel require instruments

* otel fix typo

* otel fix typo

* otel comment out net_http

* otel silence aws sdk internals

* otel silence aws sdk internals

* otel add net http

* Individually use OTEL instruments (#22082)

* Individually use OTEL instruments
with options.

* disable AwsSdk only. Checking Rack options.

* re-require awssdk even while disabled.

* disable awssdk

* disable datadog for testing

* change sequence factory to properly seed

* updated opentelemetry and datadog configs

* rack context getter initalizer

* use one at a time

* add curly braces

* Revert change

* revert change

* Revert change

* Revert change

* Remove gemfile grouping

* Remove datadog.

* ActionPack and Actionview changes

* APPEALS-44287: Excluding disposition held and select that appeal for distribution  (#22277)

* first run at an SQL query removing duplicate appeals from distribution

* code refactor and excluding disposition held and select that appeal for distribution

* automated test for the duplicate hearing bug

* fix rubocop offense SpaceInsideBlockBraces

---------

Co-authored-by: Sean Parker <Sean.Parker3@va.gov>
Co-authored-by: samasudhirreddy <sudhirreddy.sama@va.gov>

---------

Co-authored-by: Noelle Adkin <98478937+NoelleAd@users.noreply.github.com>
Co-authored-by: Raymond Hughes <131811099+raymond-hughes@users.noreply.github.com>
Co-authored-by: Dani <danielle.coleman1@va.gov>
Co-authored-by: raymond-hughes <raymond.hughes2@va.gov>
Co-authored-by: Craig Reese <109101548+craigrva@users.noreply.github.com>
Co-authored-by: Sean Parker <Sean.Parker3@va.gov>
Co-authored-by: samasudhirreddy <sudhirreddy.sama@va.gov>

* Update bundler to 2.4.22

* Updating OTEL to use all and remove new relic gem

* Remove calls to new relic

* removed id attrs in metrics service calls that were causing dimension errors

* Update config for otel

* Reorder gems to fix linting issues

* Updating config and refactoring verbose gems to add all

* Reinstall gems

* Adding all instruments

* Update config to only include basic instruments

* Update Gemfile.lock

* Adding rake to gemfile

* Adding instruments

* Comment out PG and ActiveSupport

* Suppress AWS logs

* Remove redis and turn on actionview

* Turn actionview off

* Add Redis instrumentation back

* Turn ActionPack back on

* Disable Redis

* Remove mentions of Datadog

* Removed extra mentions of Datadog

* removed newrelic references and yml file

* Test updating workflow

* Revert workflow change

* Adding simplecov back

* Fixing linting error

* Removing by: attribute after removing keyword in metric service

* Adding simplecov lcov gem and updating workflow

* Update workflow

* Updating simplecov

* Revert simple cov

* Adding featureenvy skip for reek

* Update service name. (#22762)

---------

Co-authored-by: mikefinneran <110622959+mikefinneran@users.noreply.github.com>
Co-authored-by: Noelle Adkin <98478937+NoelleAd@users.noreply.github.com>
Co-authored-by: Dani <danielle.coleman1@va.gov>
Co-authored-by: Craig Reese <109101548+craigrva@users.noreply.github.com>
Co-authored-by: Sean Parker <Sean.Parker3@va.gov>
Co-authored-by: samasudhirreddy <sudhirreddy.sama@va.gov>
Co-authored-by: Andrew Hadley <hadley_andrew@bah.com>
Co-authored-by: alex-guanipatin <alex.guanipatin@va.gov>
Co-authored-by: Drew Hadley <50673809+VandelayUtd@users.noreply.github.com>

* Remove unused variable with lint error. Re-introduce cert fixes

* Remove references to x86

* Revert "Remove references to x86"

This reverts commit fda290d.

---------

Co-authored-by: calvincostaBAH <108481161+calvincostaBAH@users.noreply.github.com>
Co-authored-by: samasudhirreddy <108430298+samasudhirreddy@users.noreply.github.com>
Co-authored-by: Calvin <Calvin.Costa@va.gov>
Co-authored-by: Craig Reese <109101548+craigrva@users.noreply.github.com>
Co-authored-by: seanrpa <155660052+seanrpa@users.noreply.github.com>
Co-authored-by: Isaiah Saucedo <irsaucedo5@gmail.com>
Co-authored-by: Craig Reese <Reese_Craig@bah.com>
Co-authored-by: Matthew Thornton <ThorntonMatthew@users.noreply.github.com>
Co-authored-by: noahhansen-gov <166541737+noahhansen-gov@users.noreply.github.com>
Co-authored-by: nhansen3 <noah.hansen1323@gmail.com>
Co-authored-by: Matthew Thornton <99351305+ThorntonMatthew@users.noreply.github.com>
Co-authored-by: prernadevbah <132498915+prernadevbah@users.noreply.github.com>
Co-authored-by: Jonathan Cohen <121630615+JCohDev@users.noreply.github.com>
Co-authored-by: Jonathan Cohen <cohen_jonathan@bah.com>
Co-authored-by: Jeremy Croteau <jcroteau@users.noreply.github.com>
Co-authored-by: Raymond Hughes <131811099+raymond-hughes@users.noreply.github.com>
Co-authored-by: mikefinneran <110622959+mikefinneran@users.noreply.github.com>
Co-authored-by: Noelle Adkin <98478937+NoelleAd@users.noreply.github.com>
Co-authored-by: Dani <danielle.coleman1@va.gov>
Co-authored-by: Sean Parker <Sean.Parker3@va.gov>
Co-authored-by: samasudhirreddy <sudhirreddy.sama@va.gov>
Co-authored-by: Andrew Hadley <hadley_andrew@bah.com>
Co-authored-by: alex-guanipatin <alex.guanipatin@va.gov>
Co-authored-by: Drew Hadley <50673809+VandelayUtd@users.noreply.github.com>
  • Loading branch information
25 people authored Sep 16, 2024
1 parent 3f08895 commit acd7828
Show file tree
Hide file tree
Showing 52 changed files with 1,325 additions and 991 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ jobs:
ports:
- 1521:1521

localstack:
image: localstack/localstack:0.14.5
ports:
- 4566:4566
env:
SERVICES: "sqs"
volumes:
- /var/run/docker.sock:/var/run/docker.sock

strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -188,6 +197,9 @@ jobs:
- name: "Wait for database"
run: dockerize -wait tcp://postgres:5432 -timeout 1m

- name: "Wait for localstack"
run: dockerize -wait tcp://localstack:4566 -timeout 30s

- name: "Wait for FACOLS"
run: ./ci-bin/capture-log "bundle exec rake local:vacols:wait_for_connection"

Expand Down
4 changes: 2 additions & 2 deletions Makefile.example
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ one-test-headless: # run the rspec test headless.
CI=1 bundle exec rspec $(RUN_ARGS) --format progress

run-all-queues: ## start shoryuken with all queues
bundle exec shoryuken -q caseflow_development_send_notifications caseflow_development_high_priority caseflow_development_low_priority -R
bundle exec shoryuken -q caseflow_development_send_notifications.fifo caseflow_development_high_priority caseflow_development_low_priority -R

run-low-priority: ## start shoryuken with just the low priority queue
bundle exec shoryuken -q caseflow_development_low_priority -R
Expand All @@ -298,7 +298,7 @@ run-high-priority: ## start shoryuken with just the high priority queue
bundle exec shoryuken -q caseflow_development_high_priority -R

run-send-notifications: ## start shoryuken with just the send_notification queue
bundle exec shoryuken -q caseflow_development_send_notifications -R
bundle exec shoryuken -q caseflow_development_send_notifications.fifo -R

jest: ## Run jest tests
cd client && yarn jest
Expand Down
67 changes: 42 additions & 25 deletions app/controllers/api/v1/va_notify_controller.rb
Original file line number Diff line number Diff line change
@@ -1,46 +1,63 @@
# frozen_string_literal: true

class Api::V1::VaNotifyController < Api::ApplicationController
# Purpose: POST request to VA Notify API to update status for a Notification entry
# Purpose: POST request to VA Notify API to update status for a Notification entry.
#
# Params: Params content can be found at https://vajira.max.gov/browse/APPEALS-21021
#
# Response: Update corresponding Notification status
def notifications_update
send "#{required_params[:notification_type]}_update"
send_sqs_message
render json: {
message: "#{params['notification_type']} Notification successfully updated: ID #{params['id']}"
}
rescue StandardError => error
log_error(error, params["id"], params["notification_type"])
render json: { error: error.message }, status: :bad_request
end

private

# Purpose: Finds and updates notification if type is email
#
# Params: Params content can be found at https://vajira.max.gov/browse/APPEALS-21021
#
# Response: Update corresponding email Notification status
def email_update
redis.set("email_update:#{required_params[:id]}:#{required_params[:status]}", 0)

render json: { message: "Email notification successfully updated: ID #{required_params[:id]}" }
def va_notify_params
params.permit(:id, :notification_type, :status, :status_reason, :to)
end

# Purpose: Finds and updates notification if type is SMS
#
# Params: Params content can be found at https://vajira.max.gov/browse/APPEALS-21021
#
# Response: Update corresponding SMS Notification status
def sms_update
redis.set("sms_update:#{required_params[:id]}:#{required_params[:status]}", 0)

render json: { message: "SMS notification successfully updated: ID #{required_params[:id]}" }
def build_message_body
id_param, notification_type_param, status_param = va_notify_params.require([:id, :notification_type, :status])

{
external_id: id_param,
notification_type: notification_type_param,
recipient: va_notify_params[:to],
status: status_param,
status_reason: va_notify_params[:status_reason]
}
rescue StandardError => error
raise error
end

def required_params
id_param, notification_type_param, status_param = params.require([:id, :notification_type, :status])
def build_sqs_message
message_body = build_message_body.to_json

{
queue_url: SqsService.find_queue_url_by_name(name: "receive_notifications"),
message_body: message_body,
message_deduplication_id: Digest::SHA256.hexdigest(message_body),
message_group_id: Constants.VA_NOTIFY_CONSTANTS.message_group_id
}
rescue StandardError => error
raise error
end

{ id: id_param, notification_type: notification_type_param, status: status_param }
def send_sqs_message
sqs = SqsService.sqs_client
sqs.send_message(build_sqs_message)
end

def redis
@redis ||= Redis.new(url: Rails.application.secrets.redis_url_cache)
def log_error(error, external_id, notification_type)
Rails.logger.error("#{error.message}\n#{error.backtrace.join("\n")}\n \
external_id: #{external_id}\n \
notification_type: #{notification_type}")
Raven.capture_exception(error)
end
end
76 changes: 76 additions & 0 deletions app/helpers/sync_decided_appeals_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# frozen_string_literal: true

##
# Helper to sync the decided appeals and their decision_mailed status

module SyncDecidedAppealsHelper
VACOLS_BATCH_PROCESS_LIMIT = ENV["VACOLS_QUERY_BATCH_SIZE"] || 800

# Syncs the decision_mailed status of Legacy Appeals with a decision made
def sync_decided_appeals
begin
# Join query to retrieve Legacy AppealState ids and corresponding vacols_id
appeal_state_ids = AppealState.legacy.where(decision_mailed: false)
.joins(:legacy_appeal).preload(:legacy_appeal)
.pluck(:id, :vacols_id)

appeal_state_ids_hash = appeal_state_ids.to_h

vacols_decision_dates = get_decision_dates(appeal_state_ids_hash.values).to_h

ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
Parallel.each(appeal_state_ids_hash, in_threads: 4) do |appeal_state_hash|
appeal_state_id = appeal_state_hash[0]
vacols_id = appeal_state_hash[1]
# If there is a decision date on the VACOLS record,
# update the decision_mailed status on the AppealState to true
if vacols_decision_dates[vacols_id].present?
AppealState.find(appeal_state_id).decision_mailed_appeal_state_update_action!
end
end
end
rescue StandardError => error
Rails.logger.error("#{error.class}: #{error.message}\n#{error.backtrace}")

# Re-raising the error so it can be caught in the NightlySyncsJob report
raise error
end
end

# Method to retrieve the decision dates from VACOLS in batches
# params: vacols_ids
# Returns: Hash containing the key, value pair of vacols_id, decision_date
def get_decision_dates(vacols_ids)
begin
decision_dates = {}

# Query VACOLS in batches
vacols_ids.in_groups_of(VACOLS_BATCH_PROCESS_LIMIT.to_i) do |vacols_id|
VACOLS::Case.where(bfkey: vacols_id).each do |vacols_record|
decision_dates[vacols_record[:bfkey]] = vacols_record[:bfddec]
end
end

decision_dates
rescue ActiveRecord::RecordNotFound
[]
end
end

def get_vacols_ids(legacy_appeal_states)
begin
vacols_ids = {}

legacy_appeal_states.each do |appeal_state|
legacy_appeal = LegacyAppeal.find(appeal_state.appeal_id)

# Find the VACOLS record associated with the LegacyAppeal
vacols_ids << { appeal_state.id.to_s => (legacy_appeal[:vacols_id]).to_s }
end

vacols_ids
rescue ActiveRecord::RecordNotFound
{}
end
end
end
12 changes: 12 additions & 0 deletions app/jobs/nightly_syncs_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
class NightlySyncsJob < CaseflowJob
queue_with_priority :low_priority
application_attr :queue # arbitrary
include SyncDecidedAppealsHelper

def perform
RequestStore.store[:current_user] = User.system_user
Expand All @@ -16,6 +17,7 @@ def perform
sync_vacols_users
sync_decision_review_tasks
sync_bgs_attorneys
sync_all_decided_appeals

slack_service.send_notification(@slack_report.join("\n"), self.class.name) if @slack_report.any?
end
Expand Down Expand Up @@ -84,6 +86,14 @@ def sync_bgs_attorneys
@slack_report << "*Fatal error in sync_bgs_attorneys:* #{error}"
end

def sync_all_decided_appeals
begin
sync_decided_appeals
rescue StandardError => error
@slack_report << "*Fatal error in sync_decided_appeals* #{error}"
end
end

def dangling_legacy_appeals
reporter = LegacyAppealsWithNoVacolsCase.new
reporter.call
Expand All @@ -105,5 +115,7 @@ def sync_hearing_states
state.scheduled_in_error_appeal_state_update_action!
end
end
rescue StandardError => error
@slack_report << "*Fatal error in sync_hearing_states* #{error}"
end
end
4 changes: 2 additions & 2 deletions app/jobs/process_decision_document_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ class ProcessDecisionDocumentJob < CaseflowJob
queue_with_priority :low_priority
application_attr :intake

def perform(decision_document_id, mail_package = nil)
def perform(decision_document_id, contested, mail_package = nil)
RequestStore.store[:application] = "idt"
RequestStore.store[:current_user] = User.system_user

DecisionDocument.find(decision_document_id).process!(mail_package)
DecisionDocument.find(decision_document_id).process!(contested, mail_package)
end
end
Loading

0 comments on commit acd7828

Please sign in to comment.