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

Conversation

seanrpa
Copy link
Contributor

@seanrpa seanrpa commented Sep 25, 2024

Resolves Update ReturnLegacyAppealsToBoardJob to use AojLegacyDocket

Description

  • Connecting ReturnLegacyAppealsToBoardJob with AOJLegacyDocket.

Acceptance Criteria

  • Code compiles correctly

Testing Plan

  1. Go to Jira Issue/Test Plan Link or list them below
  • For feature branches merging into master: Was this deployed to UAT?

Frontend

User Facing Changes

  • Screenshots of UI changes added to PR & Original Issue
BEFORE AFTER

Storybook Story

For Frontend (Presentation) Components

  • Add a Storybook file alongside the component file (e.g. create MyComponent.stories.js alongside MyComponent.jsx)
  • Give it a title that reflects the component's location within the overall Caseflow hierarchy
  • Write a separate story (within the same file) for each discrete variation of the component

Backend

Database Changes

Only for Schema Changes

  • Add typical timestamps (created_at, updated_at) for new tables
  • Update column comments; include a "PII" prefix to indicate definite or potential PII data content
  • Have your migration classes inherit from Caseflow::Migration, especially when adding indexes (use add_safe_index) (see Writing DB migrations)
  • Verify that migrate:rollback works as desired (change supported functions)
  • Perform query profiling (eyeball Rails log, check bullet and fasterer output)
  • For queries using raw sql was an explain plan run by System Team
  • Add appropriate indexes (especially for foreign keys, polymorphic columns, unique constraints, and Rails scopes)
  • Run make check-fks; add any missing foreign keys or add to config/initializers/immigrant.rb (see Record associations and Foreign Keys)
  • Add belongs_to for associations to enable the schema diagrams to be automatically updated
  • Document any non-obvious semantics or logic useful for interpreting database data at Caseflow Data Model and Dictionary

Integrations: Adding endpoints for external APIs

  • Check that Caseflow's external API code for the endpoint matches the code in the relevant integration repo
    • Request: Service name, method name, input field names
    • Response: Check expected data structure
    • Check that calls are wrapped in MetricService record block
  • Check that all configuration is coming from ENV variables
    • Listed all new ENV variables in description
    • Worked with or notified System Team that new ENV variables need to be set
  • Update Fakes
  • For feature branches: Was this tested in Caseflow 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

  • Are performance metrics (e.g., response time, throughput) being tracked?
  • Are key application components monitored (e.g., database, cache, queues)?
  • Is there a system in place for setting up alerts based on performance thresholds?

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?

@seanrpa seanrpa added the Type: design 💅 Used by the design team to keep track of design work that may need design review before shipping label Sep 25, 2024
@seanrpa seanrpa removed the Type: design 💅 Used by the design team to keep track of design work that may need design review before shipping label Sep 25, 2024
@craigrva craigrva marked this pull request as ready for review October 8, 2024 18:55
@craigrva craigrva merged commit 2fe8877 into feature/APPEALS-27523 Oct 8, 2024
16 of 17 checks passed
@craigrva craigrva deleted the SeanP/APPEALS-55152 branch October 8, 2024 18:56
craigrva added a commit that referenced this pull request Oct 14, 2024
* 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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>

* 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 <[email protected]>

* 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

* 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-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)

* Fix rubocop and tests (#22231)

* APPEALS-52222: Add seed data file for AOJ remand return feature development (#22245)

* added initial seed file

* refactor create_correspondent

* 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 <[email protected]>

* Combination/appeals 50951 50966 50980 (#22250)

* [APPEALS-50951]: Class Created for LegacyAojDocket

* draft PR

* aoj_case_docket initial work

* initial aoj case docket creation

* added missing method to aoj_case_docket

* updated legacy docket spec to remove any AOJ data

* fixed lint error

* moving aoj appeal repository file to the correct folder

* set up aoj Appeal Repository file

* remove unnecessary rubocop disable

* LegacyAojDocket

* rspec for aoj appeal repository

* updated push_priority_appeals_to_judges_job_spec.rb

* remove byebug

* fixing some rubocop errors

* fixed aoj_legacy_docket_spec

* fixed most errors in push_priority_to_judges_job_spec

* rubocop ignores/fixes

* Added count code in aoj legacy docket

* fixed last push_priority spec error

* removed unnecessary methods and reworked rspecs

* fix update_appeal_affinity method for both CaseDocket and AojCaseDocket

* remove unneccessary code

* remove duplicate methods

* resolved comments

* removed unwanted code

* remove age_of_n_oldest_genpop_priority_appeals from aoj

* removed bfhines mentions

* remove bfhines from update_appeal_affinity_dates_query

* remove bfhines testing from rspec

---------

Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Sean Parker <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* Update admin_ui_spec.rb for CAVC levers being enabled

* Appeals-43900: Update Distribution Levers Seed Values to Enable in UI (#22249)

* init. commit

* updated test with data staged

* updates to test implementation

* removed rspec factory declarations

* removed blank space

* updated seed values for aoj seeds

* updated tests

* seeds typo

* seeds typo

* added passing class methods

* review response + updates to spec

* updated name error

* updated context name

* lint fixes

* APPEALS-50870: Add New Factory Trait to VACOLS/ Case for AOJ w/ Previous Appeal (#22248)

* add legacy_aoj_appeal factory

* add tests to vacols/case model for aoj appeal factory

* add comments to factory

* kick tests

* skip flaky distribution_spec.rb tests

* update appeals ready to distribute CSV query for AOJ docket

* update admin_ui tests for AOJ levers being enabled

* Combination/appeals 43899 43901 43902 (#22429)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* added lever to related rspecs

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* skip flaky test

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

---------

Co-authored-by: Calvin <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>

* 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

* rspec addition for aoj (#22405)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* rspec addition for aoj

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* aoj affinity lever imp.

* added lever to related rspecs

* seeds

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* update to add lever to all related rspecs

* update JOIN_PREVIOUS_APPEALS constant

* skip flaky test

* lint fixes, spec fixes, and implementation updates

* seed updates

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* rspec fixes on query

* changing rspec lever test to use nonpriority method call

* updated variable name

* skipped flaky test

* fix method naming

* refactored age_of_n_nonpriority method

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

* updates to age_of_n_oldest_nonpriority method

* updates to fixx issue on lever set to infinite

* replaced num with judge.vacols_attorney_id

* rubocop fixes

* spec and update on missing parenthesis

* lint error

---------

Co-authored-by: Calvin <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* Update testing CSV files with affinity start date and original judge columns (#22498)

* affinity start date column

* original judges column for legacy and ama appeals

* remove unnecessary rubocop disable

* swap judge_mem_id with original_judge variables for better clarity

* Calvin/appeals 53712 (#22490)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* added lever to related rspecs

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* skip flaky test

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

* aoj_cavc seed data for testing

* made changes based on craigs comments

* fixed small name issues

* lint fix

---------

Co-authored-by: samasudhirreddy <[email protected]>

* Seed Data for Testing AOJ AOD Affinity Lever (#22501)

* Seed Data for Testing AOJ AOD Affinity Lever

* Name changes to Genpop

* fixed lint issue and addressed comments

* typo error fixed

* uncommented code

* Added back 2 additional appeals with Cavc

* Isaiah/appeals 43895 (#22536)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* rspec addition for aoj

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* aoj affinity lever imp.

* added lever to related rspecs

* seeds

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* update to add lever to all related rspecs

* update JOIN_PREVIOUS_APPEALS constant

* skip flaky test

* lint fixes, spec fixes, and implementation updates

* seed updates

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* rspec fixes on query

* changing rspec lever test to use nonpriority method call

* updated variable name

* skipped flaky test

* fix method naming

* refactored age_of_n_nonpriority method

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

* updates to age_of_n_oldest_nonpriority method

* updates to fixx issue on lever set to infinite

* replaced num with judge.vacols_attorney_id

* rubocop fixes

* spec and update on missing parenthesis

* lint error

* seed adjustments

* compiled updates to seed

* removed repeating methods and rearranged methods

* lint fix

* adjustments to seeds

* seed updates

* seed updates

---------

Co-authored-by: Calvin <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>

* SeanP/APPEALS-55085: Add columns to distribution_stats for new AOJ legacy docket (#22655)

* aoj_legacy_stats and aoj_legacy_priority_stats to distribution_stats table, including tests

* run make migrate to drop unnecessary local table

* add distribtuion stats to serializer in lower environments (#22559)

* Calvin/appeals 53978 (#22612)

* initial code changes + rspec fixes

* lint fixes and reorganized code

* added a skip to aoj_legacy distribution stats (must add back later)

* fixed remaining rspecs by adding to stats

* lint fix

* removing guard clauses

* removed flaky test

* Update dist controller tests for addition of distribution_stats to the serializer

* Initial commit of Affinity_date_count (#22609)

* Initial commit of Affinity_date_count

* added code in aoj legacy docket

* affinity_date_count methods for legacy docket and aoj legacy docket

* addressed comments

* refactored affinity_date_count methods and added filters

* Added rspecs and code refator

* robocop fixed

* Addressed comments and updated test cases

* Lint issue fixed

* Initial commit of Affinity_date_count

* added code in aoj legacy docket

* affinity_date_count methods for legacy docket and aoj legacy docket

* addressed comments

* refactored affinity_date_count methods and added filters

* Added rspecs and code refator

* robocop fixed

* Addressed comments and updated test cases

* Lint issue fixed

* Updated in and out affinity date window for both aoj and non aoj

* Addressed comments

* Fixed lint issue

* refactored affinity date count logic and rspecs

* fixed priority and non priority  affinity count query + rspecs

* lint issue fixed

* fixed nonpriority affinity date count method

* added comments + new method for nonpriority

---------

Co-authored-by: Calvin <[email protected]>

* APPEALS-55609: Cache case distribution lever values at beginning of PPJ or other distribution (#22654)

* method additions for cache writeouts

* moved cache methods to distribution.rb

* updates to the imp.

* added conditional on assignment

* changed order of conditional

* rspec addition & revised expiration for cache

* updates to point of method call

* updates to cache imp.

* modified removal and name of cache

* updates following review

* update to rspec

* chained rspec method to call original

* rspec fixes for aoj_case_docket

* chained method count to receive

* cleared cache on case docket spec

* fix case factory defining correspondent twice

* Calvin/appeals 57225 (#22777)

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

* add check for hearing date to levers being infinite

* fix lint

* adding method to aoj case docket

* updated rspecs

* added cache clearing

* refactored spec tests

* fixed rspec expectations

* fixed use of double update

---------

Co-authored-by: Craig Reese <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* Migrate databases after Rails upgrade

* APPEALS-57350, APPEALS-57391: Fix distribution statistics affinity_date_count methods (#22955)

* add metabase to m1 docker compose

* rename metabase container and specify a version

* add script for initial metabase setup

* script output formatting

* add metabase directory

* move to a dockerfile, implement VACOLS to setup script

* add metabase to original docker-compose

* add step to initialize metabase in demo startup

* update demo startup.sh to initialize metabase with absolute path

* add make command for local metabase setup

* fix makefile syntax error

* update scripts to work in AWS

* update demo script to use apt-get instead of yum

* update demo script to use dns for vacols-db

* fix vacols DB docker DNS name

* Distribution stats error (#22773)

* Distribution stats error

* Added test cases affinity date count

* Addressed comments and refactor genpop_by_affinity_start_date method using the OR condition

* Addressed comments

* add distribtuion stats to serializer in lower environments

---------

Co-authored-by: Craig Reese <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* APPEALS-57391: Distribution statistics method affinity_date_count does not return accurate counts for the Hearing docket (#22827)

* added method for method chaining onto scope

* chained to scope

* updated affinity_date_count method and added rspec

* added missed 'self'

* changes for pasaing test

* updates to spec and affinity_date_count

* test updates

* rubocop fixes

* rubocop fixes

* removed unused methods

---------

Co-authored-by: Craig Reese <[email protected]>

* Update test files for combining the branches

---------

Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Isaiah Saucedo <[email protected]>

* Fixed appeals ready for distribution query when no prev_deciding_judge exists

* rebased hotfix/APPEALS-58200 changes to feature branch (#23067)

* rebased hotfix/APPEALS-58200 changes to feature branch

* added aoj_case_docket changes

* updated docket coordinator spec to include levers

* Update ReturnLegacyAppealsToBoardJob to use AojLegacyDocket (#22975)

* tie return_legacy_appeals_to_board_job to AojLegacyDockets

* remove duplicate test

* testing aoj case docket appeals

* Rails logger

* getting legacy_aoj_appeal tests to work

* select PREV_TYPE_ACTION

* remove Rails logger

* change constant in self.ready_to_distribute_appeals to include hearing judge

* APPEALS-60079: Hearing held before most recent Remand Judge distributing correctly when lever is set to infinite (#23115)

* update infinite lever checks to use deciding instead of hearing judge

* fix bug in seed data with user css_id lengths

* Craig/appeals 60680 (#23177)

* add test scenario and update assertions for SMR changes

* update test assertions for hearing after decision checks

* code change for tying cases with a nil previous deciding judge

* updated seed veteran names for new scenarios

---------

Co-authored-by: calvincostaBAH <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Calvin <[email protected]>
Co-authored-by: seanrpa <[email protected]>
Co-authored-by: Isaiah Saucedo <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Sean Parker <[email protected]>
craigrva added a commit that referenced this pull request Oct 16, 2024
* 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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>

* 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 <[email protected]>

* 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

* 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-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)

* Fix rubocop and tests (#22231)

* APPEALS-52222: Add seed data file for AOJ remand return feature development (#22245)

* added initial seed file

* refactor create_correspondent

* 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 <[email protected]>

* Combination/appeals 50951 50966 50980 (#22250)

* [APPEALS-50951]: Class Created for LegacyAojDocket

* draft PR

* aoj_case_docket initial work

* initial aoj case docket creation

* added missing method to aoj_case_docket

* updated legacy docket spec to remove any AOJ data

* fixed lint error

* moving aoj appeal repository file to the correct folder

* set up aoj Appeal Repository file

* remove unnecessary rubocop disable

* LegacyAojDocket

* rspec for aoj appeal repository

* updated push_priority_appeals_to_judges_job_spec.rb

* remove byebug

* fixing some rubocop errors

* fixed aoj_legacy_docket_spec

* fixed most errors in push_priority_to_judges_job_spec

* rubocop ignores/fixes

* Added count code in aoj legacy docket

* fixed last push_priority spec error

* removed unnecessary methods and reworked rspecs

* fix update_appeal_affinity method for both CaseDocket and AojCaseDocket

* remove unneccessary code

* remove duplicate methods

* resolved comments

* removed unwanted code

* remove age_of_n_oldest_genpop_priority_appeals from aoj

* removed bfhines mentions

* remove bfhines from update_appeal_affinity_dates_query

* remove bfhines testing from rspec

---------

Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Sean Parker <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* Update admin_ui_spec.rb for CAVC levers being enabled

* Appeals-43900: Update Distribution Levers Seed Values to Enable in UI (#22249)

* init. commit

* updated test with data staged

* updates to test implementation

* removed rspec factory declarations

* removed blank space

* updated seed values for aoj seeds

* updated tests

* seeds typo

* seeds typo

* added passing class methods

* review response + updates to spec

* updated name error

* updated context name

* lint fixes

* APPEALS-50870: Add New Factory Trait to VACOLS/ Case for AOJ w/ Previous Appeal (#22248)

* add legacy_aoj_appeal factory

* add tests to vacols/case model for aoj appeal factory

* add comments to factory

* kick tests

* skip flaky distribution_spec.rb tests

* update appeals ready to distribute CSV query for AOJ docket

* update admin_ui tests for AOJ levers being enabled

* Combination/appeals 43899 43901 43902 (#22429)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* added lever to related rspecs

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* skip flaky test

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

---------

Co-authored-by: Calvin <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>

* 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

* rspec addition for aoj (#22405)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* rspec addition for aoj

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* aoj affinity lever imp.

* added lever to related rspecs

* seeds

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* update to add lever to all related rspecs

* update JOIN_PREVIOUS_APPEALS constant

* skip flaky test

* lint fixes, spec fixes, and implementation updates

* seed updates

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* rspec fixes on query

* changing rspec lever test to use nonpriority method call

* updated variable name

* skipped flaky test

* fix method naming

* refactored age_of_n_nonpriority method

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

* updates to age_of_n_oldest_nonpriority method

* updates to fixx issue on lever set to infinite

* replaced num with judge.vacols_attorney_id

* rubocop fixes

* spec and update on missing parenthesis

* lint error

---------

Co-authored-by: Calvin <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* Update testing CSV files with affinity start date and original judge columns (#22498)

* affinity start date column

* original judges column for legacy and ama appeals

* remove unnecessary rubocop disable

* swap judge_mem_id with original_judge variables for better clarity

* Calvin/appeals 53712 (#22490)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* added lever to related rspecs

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* skip flaky test

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

* aoj_cavc seed data for testing

* made changes based on craigs comments

* fixed small name issues

* lint fix

---------

Co-authored-by: samasudhirreddy <[email protected]>

* Seed Data for Testing AOJ AOD Affinity Lever (#22501)

* Seed Data for Testing AOJ AOD Affinity Lever

* Name changes to Genpop

* fixed lint issue and addressed comments

* typo error fixed

* uncommented code

* Added back 2 additional appeals with Cavc

* Isaiah/appeals 43895 (#22536)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* rspec addition for aoj

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* aoj affinity lever imp.

* added lever to related rspecs

* seeds

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* update to add lever to all related rspecs

* update JOIN_PREVIOUS_APPEALS constant

* skip flaky test

* lint fixes, spec fixes, and implementation updates

* seed updates

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* rspec fixes on query

* changing rspec lever test to use nonpriority method call

* updated variable name

* skipped flaky test

* fix method naming

* refactored age_of_n_nonpriority method

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

* updates to age_of_n_oldest_nonpriority method

* updates to fixx issue on lever set to infinite

* replaced num with judge.vacols_attorney_id

* rubocop fixes

* spec and update on missing parenthesis

* lint error

* seed adjustments

* compiled updates to seed

* removed repeating methods and rearranged methods

* lint fix

* adjustments to seeds

* seed updates

* seed updates

---------

Co-authored-by: Calvin <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>

* SeanP/APPEALS-55085: Add columns to distribution_stats for new AOJ legacy docket (#22655)

* aoj_legacy_stats and aoj_legacy_priority_stats to distribution_stats table, including tests

* run make migrate to drop unnecessary local table

* add distribtuion stats to serializer in lower environments (#22559)

* Calvin/appeals 53978 (#22612)

* initial code changes + rspec fixes

* lint fixes and reorganized code

* added a skip to aoj_legacy distribution stats (must add back later)

* fixed remaining rspecs by adding to stats

* lint fix

* removing guard clauses

* removed flaky test

* Update dist controller tests for addition of distribution_stats to the serializer

* Initial commit of Affinity_date_count (#22609)

* Initial commit of Affinity_date_count

* added code in aoj legacy docket

* affinity_date_count methods for legacy docket and aoj legacy docket

* addressed comments

* refactored affinity_date_count methods and added filters

* Added rspecs and code refator

* robocop fixed

* Addressed comments and updated test cases

* Lint issue fixed

* Initial commit of Affinity_date_count

* added code in aoj legacy docket

* affinity_date_count methods for legacy docket and aoj legacy docket

* addressed comments

* refactored affinity_date_count methods and added filters

* Added rspecs and code refator

* robocop fixed

* Addressed comments and updated test cases

* Lint issue fixed

* Updated in and out affinity date window for both aoj and non aoj

* Addressed comments

* Fixed lint issue

* refactored affinity date count logic and rspecs

* fixed priority and non priority  affinity count query + rspecs

* lint issue fixed

* fixed nonpriority affinity date count method

* added comments + new method for nonpriority

---------

Co-authored-by: Calvin <[email protected]>

* APPEALS-55609: Cache case distribution lever values at beginning of PPJ or other distribution (#22654)

* method additions for cache writeouts

* moved cache methods to distribution.rb

* updates to the imp.

* added conditional on assignment

* changed order of conditional

* rspec addition & revised expiration for cache

* updates to point of method call

* updates to cache imp.

* modified removal and name of cache

* updates following review

* update to rspec

* chained rspec method to call original

* rspec fixes for aoj_case_docket

* chained method count to receive

* cleared cache on case docket spec

* fix case factory defining correspondent twice

* Calvin/appeals 57225 (#22777)

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

* add check for hearing date to levers being infinite

* fix lint

* adding method to aoj case docket

* updated rspecs

* added cache clearing

* refactored spec tests

* fixed rspec expectations

* fixed use of double update

---------

Co-authored-by: Craig Reese <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* Migrate databases after Rails upgrade

* APPEALS-57350, APPEALS-57391: Fix distribution statistics affinity_date_count methods (#22955)

* add metabase to m1 docker compose

* rename metabase container and specify a version

* add script for initial metabase setup

* script output formatting

* add metabase directory

* move to a dockerfile, implement VACOLS to setup script

* add metabase to original docker-compose

* add step to initialize metabase in demo startup

* update demo startup.sh to initialize metabase with absolute path

* add make command for local metabase setup

* fix makefile syntax error

* update scripts to work in AWS

* update demo script to use apt-get instead of yum

* update demo script to use dns for vacols-db

* fix vacols DB docker DNS name

* Distribution stats error (#22773)

* Distribution stats error

* Added test cases affinity date count

* Addressed comments and refactor genpop_by_affinity_start_date method using the OR condition

* Addressed comments

* add distribtuion stats to serializer in lower environments

---------

Co-authored-by: Craig Reese <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* APPEALS-57391: Distribution statistics method affinity_date_count does not return accurate counts for the Hearing docket (#22827)

* added method for method chaining onto scope

* chained to scope

* updated affinity_date_count method and added rspec

* added missed 'self'

* changes for pasaing test

* updates to spec and affinity_date_count

* test updates

* rubocop fixes

* rubocop fixes

* removed unused methods

---------

Co-authored-by: Craig Reese <[email protected]>

* Update test files for combining the branches

---------

Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Isaiah Saucedo <[email protected]>

* Fixed appeals ready for distribution query when no prev_deciding_judge exists

* rebased hotfix/APPEALS-58200 changes to feature branch (#23067)

* rebased hotfix/APPEALS-58200 changes to feature branch

* added aoj_case_docket changes

* updated docket coordinator spec to include levers

* Update ReturnLegacyAppealsToBoardJob to use AojLegacyDocket (#22975)

* tie return_legacy_appeals_to_board_job to AojLegacyDockets

* remove duplicate test

* testing aoj case docket appeals

* Rails logger

* getting legacy_aoj_appeal tests to work

* select PREV_TYPE_ACTION

* remove Rails logger

* change constant in self.ready_to_distribute_appeals to include hearing judge

* APPEALS-60079: Hearing held before most recent Remand Judge distributing correctly when lever is set to infinite (#23115)

* update infinite lever checks to use deciding instead of hearing judge

* fix bug in seed data with user css_id lengths

* Craig/appeals 60680 (#23177)

* add test scenario and update assertions for SMR changes

* update test assertions for hearing after decision checks

* code change for tying cases with a nil previous deciding judge

* updated seed veteran names for new scenarios

* Add checks for disable_legacy Case Distribution Levers to the AOJ legacy docket

---------

Co-authored-by: calvincostaBAH <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Calvin <[email protected]>
Co-authored-by: seanrpa <[email protected]>
Co-authored-by: Isaiah Saucedo <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Sean Parker <[email protected]>
craigrva added a commit that referenced this pull request Oct 16, 2024
* 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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>

* 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 <[email protected]>

* 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

* 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-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)

* Fix rubocop and tests (#22231)

* APPEALS-52222: Add seed data file for AOJ remand return feature development (#22245)

* added initial seed file

* refactor create_correspondent

* 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 <[email protected]>

* Combination/appeals 50951 50966 50980 (#22250)

* [APPEALS-50951]: Class Created for LegacyAojDocket

* draft PR

* aoj_case_docket initial work

* initial aoj case docket creation

* added missing method to aoj_case_docket

* updated legacy docket spec to remove any AOJ data

* fixed lint error

* moving aoj appeal repository file to the correct folder

* set up aoj Appeal Repository file

* remove unnecessary rubocop disable

* LegacyAojDocket

* rspec for aoj appeal repository

* updated push_priority_appeals_to_judges_job_spec.rb

* remove byebug

* fixing some rubocop errors

* fixed aoj_legacy_docket_spec

* fixed most errors in push_priority_to_judges_job_spec

* rubocop ignores/fixes

* Added count code in aoj legacy docket

* fixed last push_priority spec error

* removed unnecessary methods and reworked rspecs

* fix update_appeal_affinity method for both CaseDocket and AojCaseDocket

* remove unneccessary code

* remove duplicate methods

* resolved comments

* removed unwanted code

* remove age_of_n_oldest_genpop_priority_appeals from aoj

* removed bfhines mentions

* remove bfhines from update_appeal_affinity_dates_query

* remove bfhines testing from rspec

---------

Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Sean Parker <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* Update admin_ui_spec.rb for CAVC levers being enabled

* Appeals-43900: Update Distribution Levers Seed Values to Enable in UI (#22249)

* init. commit

* updated test with data staged

* updates to test implementation

* removed rspec factory declarations

* removed blank space

* updated seed values for aoj seeds

* updated tests

* seeds typo

* seeds typo

* added passing class methods

* review response + updates to spec

* updated name error

* updated context name

* lint fixes

* APPEALS-50870: Add New Factory Trait to VACOLS/ Case for AOJ w/ Previous Appeal (#22248)

* add legacy_aoj_appeal factory

* add tests to vacols/case model for aoj appeal factory

* add comments to factory

* kick tests

* skip flaky distribution_spec.rb tests

* update appeals ready to distribute CSV query for AOJ docket

* update admin_ui tests for AOJ levers being enabled

* Combination/appeals 43899 43901 43902 (#22429)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* added lever to related rspecs

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* skip flaky test

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

---------

Co-authored-by: Calvin <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>

* 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

* rspec addition for aoj (#22405)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* rspec addition for aoj

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* aoj affinity lever imp.

* added lever to related rspecs

* seeds

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* update to add lever to all related rspecs

* update JOIN_PREVIOUS_APPEALS constant

* skip flaky test

* lint fixes, spec fixes, and implementation updates

* seed updates

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* rspec fixes on query

* changing rspec lever test to use nonpriority method call

* updated variable name

* skipped flaky test

* fix method naming

* refactored age_of_n_nonpriority method

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

* updates to age_of_n_oldest_nonpriority method

* updates to fixx issue on lever set to infinite

* replaced num with judge.vacols_attorney_id

* rubocop fixes

* spec and update on missing parenthesis

* lint error

---------

Co-authored-by: Calvin <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* Update testing CSV files with affinity start date and original judge columns (#22498)

* affinity start date column

* original judges column for legacy and ama appeals

* remove unnecessary rubocop disable

* swap judge_mem_id with original_judge variables for better clarity

* Calvin/appeals 53712 (#22490)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* added lever to related rspecs

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* skip flaky test

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

* aoj_cavc seed data for testing

* made changes based on craigs comments

* fixed small name issues

* lint fix

---------

Co-authored-by: samasudhirreddy <[email protected]>

* Seed Data for Testing AOJ AOD Affinity Lever (#22501)

* Seed Data for Testing AOJ AOD Affinity Lever

* Name changes to Genpop

* fixed lint issue and addressed comments

* typo error fixed

* uncommented code

* Added back 2 additional appeals with Cavc

* Isaiah/appeals 43895 (#22536)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* rspec addition for aoj

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* aoj affinity lever imp.

* added lever to related rspecs

* seeds

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* update to add lever to all related rspecs

* update JOIN_PREVIOUS_APPEALS constant

* skip flaky test

* lint fixes, spec fixes, and implementation updates

* seed updates

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* rspec fixes on query

* changing rspec lever test to use nonpriority method call

* updated variable name

* skipped flaky test

* fix method naming

* refactored age_of_n_nonpriority method

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

* updates to age_of_n_oldest_nonpriority method

* updates to fixx issue on lever set to infinite

* replaced num with judge.vacols_attorney_id

* rubocop fixes

* spec and update on missing parenthesis

* lint error

* seed adjustments

* compiled updates to seed

* removed repeating methods and rearranged methods

* lint fix

* adjustments to seeds

* seed updates

* seed updates

---------

Co-authored-by: Calvin <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>

* SeanP/APPEALS-55085: Add columns to distribution_stats for new AOJ legacy docket (#22655)

* aoj_legacy_stats and aoj_legacy_priority_stats to distribution_stats table, including tests

* run make migrate to drop unnecessary local table

* add distribtuion stats to serializer in lower environments (#22559)

* Calvin/appeals 53978 (#22612)

* initial code changes + rspec fixes

* lint fixes and reorganized code

* added a skip to aoj_legacy distribution stats (must add back later)

* fixed remaining rspecs by adding to stats

* lint fix

* removing guard clauses

* removed flaky test

* Update dist controller tests for addition of distribution_stats to the serializer

* Initial commit of Affinity_date_count (#22609)

* Initial commit of Affinity_date_count

* added code in aoj legacy docket

* affinity_date_count methods for legacy docket and aoj legacy docket

* addressed comments

* refactored affinity_date_count methods and added filters

* Added rspecs and code refator

* robocop fixed

* Addressed comments and updated test cases

* Lint issue fixed

* Initial commit of Affinity_date_count

* added code in aoj legacy docket

* affinity_date_count methods for legacy docket and aoj legacy docket

* addressed comments

* refactored affinity_date_count methods and added filters

* Added rspecs and code refator

* robocop fixed

* Addressed comments and updated test cases

* Lint issue fixed

* Updated in and out affinity date window for both aoj and non aoj

* Addressed comments

* Fixed lint issue

* refactored affinity date count logic and rspecs

* fixed priority and non priority  affinity count query + rspecs

* lint issue fixed

* fixed nonpriority affinity date count method

* added comments + new method for nonpriority

---------

Co-authored-by: Calvin <[email protected]>

* APPEALS-55609: Cache case distribution lever values at beginning of PPJ or other distribution (#22654)

* method additions for cache writeouts

* moved cache methods to distribution.rb

* updates to the imp.

* added conditional on assignment

* changed order of conditional

* rspec addition & revised expiration for cache

* updates to point of method call

* updates to cache imp.

* modified removal and name of cache

* updates following review

* update to rspec

* chained rspec method to call original

* rspec fixes for aoj_case_docket

* chained method count to receive

* cleared cache on case docket spec

* fix case factory defining correspondent twice

* Calvin/appeals 57225 (#22777)

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

* add check for hearing date to levers being infinite

* fix lint

* adding method to aoj case docket

* updated rspecs

* added cache clearing

* refactored spec tests

* fixed rspec expectations

* fixed use of double update

---------

Co-authored-by: Craig Reese <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* Migrate databases after Rails upgrade

* APPEALS-57350, APPEALS-57391: Fix distribution statistics affinity_date_count methods (#22955)

* add metabase to m1 docker compose

* rename metabase container and specify a version

* add script for initial metabase setup

* script output formatting

* add metabase directory

* move to a dockerfile, implement VACOLS to setup script

* add metabase to original docker-compose

* add step to initialize metabase in demo startup

* update demo startup.sh to initialize metabase with absolute path

* add make command for local metabase setup

* fix makefile syntax error

* update scripts to work in AWS

* update demo script to use apt-get instead of yum

* update demo script to use dns for vacols-db

* fix vacols DB docker DNS name

* Distribution stats error (#22773)

* Distribution stats error

* Added test cases affinity date count

* Addressed comments and refactor genpop_by_affinity_start_date method using the OR condition

* Addressed comments

* add distribtuion stats to serializer in lower environments

---------

Co-authored-by: Craig Reese <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* APPEALS-57391: Distribution statistics method affinity_date_count does not return accurate counts for the Hearing docket (#22827)

* added method for method chaining onto scope

* chained to scope

* updated affinity_date_count method and added rspec

* added missed 'self'

* changes for pasaing test

* updates to spec and affinity_date_count

* test updates

* rubocop fixes

* rubocop fixes

* removed unused methods

---------

Co-authored-by: Craig Reese <[email protected]>

* Update test files for combining the branches

---------

Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Isaiah Saucedo <[email protected]>

* Fixed appeals ready for distribution query when no prev_deciding_judge exists

* rebased hotfix/APPEALS-58200 changes to feature branch (#23067)

* rebased hotfix/APPEALS-58200 changes to feature branch

* added aoj_case_docket changes

* updated docket coordinator spec to include levers

* Update ReturnLegacyAppealsToBoardJob to use AojLegacyDocket (#22975)

* tie return_legacy_appeals_to_board_job to AojLegacyDockets

* remove duplicate test

* testing aoj case docket appeals

* Rails logger

* getting legacy_aoj_appeal tests to work

* select PREV_TYPE_ACTION

* remove Rails logger

* change constant in self.ready_to_distribute_appeals to include hearing judge

* APPEALS-60079: Hearing held before most recent Remand Judge distributing correctly when lever is set to infinite (#23115)

* update infinite lever checks to use deciding instead of hearing judge

* fix bug in seed data with user css_id lengths

* Craig/appeals 60680 (#23177)

* add test scenario and update assertions for SMR changes

* update test assertions for hearing after decision checks

* code change for tying cases with a nil previous deciding judge

* updated seed veteran names for new scenarios

* Add checks for disable_legacy Case Distribution Levers to the AOJ legacy docket

---------

Co-authored-by: calvincostaBAH <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Calvin <[email protected]>
Co-authored-by: seanrpa <[email protected]>
Co-authored-by: Isaiah Saucedo <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Sean Parker <[email protected]>
craigrva added a commit that referenced this pull request Oct 25, 2024
* 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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>

* 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 <[email protected]>

* 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

* 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-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)

* Fix rubocop and tests (#22231)

* APPEALS-52222: Add seed data file for AOJ remand return feature development (#22245)

* added initial seed file

* refactor create_correspondent

* 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 <[email protected]>

* Combination/appeals 50951 50966 50980 (#22250)

* [APPEALS-50951]: Class Created for LegacyAojDocket

* draft PR

* aoj_case_docket initial work

* initial aoj case docket creation

* added missing method to aoj_case_docket

* updated legacy docket spec to remove any AOJ data

* fixed lint error

* moving aoj appeal repository file to the correct folder

* set up aoj Appeal Repository file

* remove unnecessary rubocop disable

* LegacyAojDocket

* rspec for aoj appeal repository

* updated push_priority_appeals_to_judges_job_spec.rb

* remove byebug

* fixing some rubocop errors

* fixed aoj_legacy_docket_spec

* fixed most errors in push_priority_to_judges_job_spec

* rubocop ignores/fixes

* Added count code in aoj legacy docket

* fixed last push_priority spec error

* removed unnecessary methods and reworked rspecs

* fix update_appeal_affinity method for both CaseDocket and AojCaseDocket

* remove unneccessary code

* remove duplicate methods

* resolved comments

* removed unwanted code

* remove age_of_n_oldest_genpop_priority_appeals from aoj

* removed bfhines mentions

* remove bfhines from update_appeal_affinity_dates_query

* remove bfhines testing from rspec

---------

Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Sean Parker <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* Update admin_ui_spec.rb for CAVC levers being enabled

* Appeals-43900: Update Distribution Levers Seed Values to Enable in UI (#22249)

* init. commit

* updated test with data staged

* updates to test implementation

* removed rspec factory declarations

* removed blank space

* updated seed values for aoj seeds

* updated tests

* seeds typo

* seeds typo

* added passing class methods

* review response + updates to spec

* updated name error

* updated context name

* lint fixes

* APPEALS-50870: Add New Factory Trait to VACOLS/ Case for AOJ w/ Previous Appeal (#22248)

* add legacy_aoj_appeal factory

* add tests to vacols/case model for aoj appeal factory

* add comments to factory

* kick tests

* skip flaky distribution_spec.rb tests

* update appeals ready to distribute CSV query for AOJ docket

* update admin_ui tests for AOJ levers being enabled

* Combination/appeals 43899 43901 43902 (#22429)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* added lever to related rspecs

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* skip flaky test

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

---------

Co-authored-by: Calvin <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>

* 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

* rspec addition for aoj (#22405)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* rspec addition for aoj

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* aoj affinity lever imp.

* added lever to related rspecs

* seeds

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* update to add lever to all related rspecs

* update JOIN_PREVIOUS_APPEALS constant

* skip flaky test

* lint fixes, spec fixes, and implementation updates

* seed updates

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* rspec fixes on query

* changing rspec lever test to use nonpriority method call

* updated variable name

* skipped flaky test

* fix method naming

* refactored age_of_n_nonpriority method

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

* updates to age_of_n_oldest_nonpriority method

* updates to fixx issue on lever set to infinite

* replaced num with judge.vacols_attorney_id

* rubocop fixes

* spec and update on missing parenthesis

* lint error

---------

Co-authored-by: Calvin <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* Update testing CSV files with affinity start date and original judge columns (#22498)

* affinity start date column

* original judges column for legacy and ama appeals

* remove unnecessary rubocop disable

* swap judge_mem_id with original_judge variables for better clarity

* Calvin/appeals 53712 (#22490)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* added lever to related rspecs

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* skip flaky test

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

* aoj_cavc seed data for testing

* made changes based on craigs comments

* fixed small name issues

* lint fix

---------

Co-authored-by: samasudhirreddy <[email protected]>

* Seed Data for Testing AOJ AOD Affinity Lever (#22501)

* Seed Data for Testing AOJ AOD Affinity Lever

* Name changes to Genpop

* fixed lint issue and addressed comments

* typo error fixed

* uncommented code

* Added back 2 additional appeals with Cavc

* Isaiah/appeals 43895 (#22536)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* rspec addition for aoj

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* aoj affinity lever imp.

* added lever to related rspecs

* seeds

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* update to add lever to all related rspecs

* update JOIN_PREVIOUS_APPEALS constant

* skip flaky test

* lint fixes, spec fixes, and implementation updates

* seed updates

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* rspec fixes on query

* changing rspec lever test to use nonpriority method call

* updated variable name

* skipped flaky test

* fix method naming

* refactored age_of_n_nonpriority method

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

* updates to age_of_n_oldest_nonpriority method

* updates to fixx issue on lever set to infinite

* replaced num with judge.vacols_attorney_id

* rubocop fixes

* spec and update on missing parenthesis

* lint error

* seed adjustments

* compiled updates to seed

* removed repeating methods and rearranged methods

* lint fix

* adjustments to seeds

* seed updates

* seed updates

---------

Co-authored-by: Calvin <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>

* SeanP/APPEALS-55085: Add columns to distribution_stats for new AOJ legacy docket (#22655)

* aoj_legacy_stats and aoj_legacy_priority_stats to distribution_stats table, including tests

* run make migrate to drop unnecessary local table

* add distribtuion stats to serializer in lower environments (#22559)

* Calvin/appeals 53978 (#22612)

* initial code changes + rspec fixes

* lint fixes and reorganized code

* added a skip to aoj_legacy distribution stats (must add back later)

* fixed remaining rspecs by adding to stats

* lint fix

* removing guard clauses

* removed flaky test

* Update dist controller tests for addition of distribution_stats to the serializer

* Initial commit of Affinity_date_count (#22609)

* Initial commit of Affinity_date_count

* added code in aoj legacy docket

* affinity_date_count methods for legacy docket and aoj legacy docket

* addressed comments

* refactored affinity_date_count methods and added filters

* Added rspecs and code refator

* robocop fixed

* Addressed comments and updated test cases

* Lint issue fixed

* Initial commit of Affinity_date_count

* added code in aoj legacy docket

* affinity_date_count methods for legacy docket and aoj legacy docket

* addressed comments

* refactored affinity_date_count methods and added filters

* Added rspecs and code refator

* robocop fixed

* Addressed comments and updated test cases

* Lint issue fixed

* Updated in and out affinity date window for both aoj and non aoj

* Addressed comments

* Fixed lint issue

* refactored affinity date count logic and rspecs

* fixed priority and non priority  affinity count query + rspecs

* lint issue fixed

* fixed nonpriority affinity date count method

* added comments + new method for nonpriority

---------

Co-authored-by: Calvin <[email protected]>

* APPEALS-55609: Cache case distribution lever values at beginning of PPJ or other distribution (#22654)

* method additions for cache writeouts

* moved cache methods to distribution.rb

* updates to the imp.

* added conditional on assignment

* changed order of conditional

* rspec addition & revised expiration for cache

* updates to point of method call

* updates to cache imp.

* modified removal and name of cache

* updates following review

* update to rspec

* chained rspec method to call original

* rspec fixes for aoj_case_docket

* chained method count to receive

* cleared cache on case docket spec

* fix case factory defining correspondent twice

* Calvin/appeals 57225 (#22777)

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

* add check for hearing date to levers being infinite

* fix lint

* adding method to aoj case docket

* updated rspecs

* added cache clearing

* refactored spec tests

* fixed rspec expectations

* fixed use of double update

---------

Co-authored-by: Craig Reese <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* Migrate databases after Rails upgrade

* APPEALS-57350, APPEALS-57391: Fix distribution statistics affinity_date_count methods (#22955)

* add metabase to m1 docker compose

* rename metabase container and specify a version

* add script for initial metabase setup

* script output formatting

* add metabase directory

* move to a dockerfile, implement VACOLS to setup script

* add metabase to original docker-compose

* add step to initialize metabase in demo startup

* update demo startup.sh to initialize metabase with absolute path

* add make command for local metabase setup

* fix makefile syntax error

* update scripts to work in AWS

* update demo script to use apt-get instead of yum

* update demo script to use dns for vacols-db

* fix vacols DB docker DNS name

* Distribution stats error (#22773)

* Distribution stats error

* Added test cases affinity date count

* Addressed comments and refactor genpop_by_affinity_start_date method using the OR condition

* Addressed comments

* add distribtuion stats to serializer in lower environments

---------

Co-authored-by: Craig Reese <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* APPEALS-57391: Distribution statistics method affinity_date_count does not return accurate counts for the Hearing docket (#22827)

* added method for method chaining onto scope

* chained to scope

* updated affinity_date_count method and added rspec

* added missed 'self'

* changes for pasaing test

* updates to spec and affinity_date_count

* test updates

* rubocop fixes

* rubocop fixes

* removed unused methods

---------

Co-authored-by: Craig Reese <[email protected]>

* Update test files for combining the branches

---------

Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Isaiah Saucedo <[email protected]>

* Fixed appeals ready for distribution query when no prev_deciding_judge exists

* rebased hotfix/APPEALS-58200 changes to feature branch (#23067)

* rebased hotfix/APPEALS-58200 changes to feature branch

* added aoj_case_docket changes

* updated docket coordinator spec to include levers

* Update ReturnLegacyAppealsToBoardJob to use AojLegacyDocket (#22975)

* tie return_legacy_appeals_to_board_job to AojLegacyDockets

* remove duplicate test

* testing aoj case docket appeals

* Rails logger

* getting legacy_aoj_appeal tests to work

* select PREV_TYPE_ACTION

* remove Rails logger

* change constant in self.ready_to_distribute_appeals to include hearing judge

* APPEALS-60079: Hearing held before most recent Remand Judge distributing correctly when lever is set to infinite (#23115)

* update infinite lever checks to use deciding instead of hearing judge

* fix bug in seed data with user css_id lengths

* Craig/appeals 60680 (#23177)

* add test scenario and update assertions for SMR changes

* update test assertions for hearing after decision checks

* code change for tying cases with a nil previous deciding judge

* updated seed veteran names for new scenarios

* Add checks for disable_legacy Case Distribution Levers to the AOJ legacy docket

* APPEALS-61180: Improve Performance of the AOJ Distribution Queries (#23268)

* add feature toggles to AMA statistics to allow disabling of certain queries

* set case_docket counts method to only count if the appeal is not a post remand

* refactor affinity filters for performance

* refactor cavc filters in case_docket for performance

* fix rubocop warnings

* refactor for reduce repetition

* refactor repeated code in affinity filters to a common method

* fix rubocop warnings in case docket files

* update code comments for consistency in methods

* add test for distribution stats behavior with disable stats toggles turned on

* add automated test to validate new feature toggle behavior

* update tests for .counts_by_priority_and_readiness

* add comment to case docket spec

* Add new feature toggle to local/demo disable list

* remove distribution stats generation from the initial transaction to reduce time for users to get their cases

* add aoj to aoj repository metrics logs

---------

Co-authored-by: calvincostaBAH <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Calvin <[email protected]>
Co-authored-by: seanrpa <[email protected]>
Co-authored-by: Isaiah Saucedo <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Sean Parker <[email protected]>
craigrva added a commit that referenced this pull request Oct 28, 2024
* 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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>

* 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 <[email protected]>

* 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

* 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-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)

* Fix rubocop and tests (#22231)

* APPEALS-52222: Add seed data file for AOJ remand return feature development (#22245)

* added initial seed file

* refactor create_correspondent

* 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 <[email protected]>

* Combination/appeals 50951 50966 50980 (#22250)

* [APPEALS-50951]: Class Created for LegacyAojDocket

* draft PR

* aoj_case_docket initial work

* initial aoj case docket creation

* added missing method to aoj_case_docket

* updated legacy docket spec to remove any AOJ data

* fixed lint error

* moving aoj appeal repository file to the correct folder

* set up aoj Appeal Repository file

* remove unnecessary rubocop disable

* LegacyAojDocket

* rspec for aoj appeal repository

* updated push_priority_appeals_to_judges_job_spec.rb

* remove byebug

* fixing some rubocop errors

* fixed aoj_legacy_docket_spec

* fixed most errors in push_priority_to_judges_job_spec

* rubocop ignores/fixes

* Added count code in aoj legacy docket

* fixed last push_priority spec error

* removed unnecessary methods and reworked rspecs

* fix update_appeal_affinity method for both CaseDocket and AojCaseDocket

* remove unneccessary code

* remove duplicate methods

* resolved comments

* removed unwanted code

* remove age_of_n_oldest_genpop_priority_appeals from aoj

* removed bfhines mentions

* remove bfhines from update_appeal_affinity_dates_query

* remove bfhines testing from rspec

---------

Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Sean Parker <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* Update admin_ui_spec.rb for CAVC levers being enabled

* Appeals-43900: Update Distribution Levers Seed Values to Enable in UI (#22249)

* init. commit

* updated test with data staged

* updates to test implementation

* removed rspec factory declarations

* removed blank space

* updated seed values for aoj seeds

* updated tests

* seeds typo

* seeds typo

* added passing class methods

* review response + updates to spec

* updated name error

* updated context name

* lint fixes

* APPEALS-50870: Add New Factory Trait to VACOLS/ Case for AOJ w/ Previous Appeal (#22248)

* add legacy_aoj_appeal factory

* add tests to vacols/case model for aoj appeal factory

* add comments to factory

* kick tests

* skip flaky distribution_spec.rb tests

* update appeals ready to distribute CSV query for AOJ docket

* update admin_ui tests for AOJ levers being enabled

* Combination/appeals 43899 43901 43902 (#22429)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* added lever to related rspecs

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* skip flaky test

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

---------

Co-authored-by: Calvin <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>

* 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

* rspec addition for aoj (#22405)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* rspec addition for aoj

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* aoj affinity lever imp.

* added lever to related rspecs

* seeds

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* update to add lever to all related rspecs

* update JOIN_PREVIOUS_APPEALS constant

* skip flaky test

* lint fixes, spec fixes, and implementation updates

* seed updates

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* rspec fixes on query

* changing rspec lever test to use nonpriority method call

* updated variable name

* skipped flaky test

* fix method naming

* refactored age_of_n_nonpriority method

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

* updates to age_of_n_oldest_nonpriority method

* updates to fixx issue on lever set to infinite

* replaced num with judge.vacols_attorney_id

* rubocop fixes

* spec and update on missing parenthesis

* lint error

---------

Co-authored-by: Calvin <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* Update testing CSV files with affinity start date and original judge columns (#22498)

* affinity start date column

* original judges column for legacy and ama appeals

* remove unnecessary rubocop disable

* swap judge_mem_id with original_judge variables for better clarity

* Calvin/appeals 53712 (#22490)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* added lever to related rspecs

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* skip flaky test

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

* aoj_cavc seed data for testing

* made changes based on craigs comments

* fixed small name issues

* lint fix

---------

Co-authored-by: samasudhirreddy <[email protected]>

* Seed Data for Testing AOJ AOD Affinity Lever (#22501)

* Seed Data for Testing AOJ AOD Affinity Lever

* Name changes to Genpop

* fixed lint issue and addressed comments

* typo error fixed

* uncommented code

* Added back 2 additional appeals with Cavc

* Isaiah/appeals 43895 (#22536)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* rspec addition for aoj

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* aoj affinity lever imp.

* added lever to related rspecs

* seeds

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* update to add lever to all related rspecs

* update JOIN_PREVIOUS_APPEALS constant

* skip flaky test

* lint fixes, spec fixes, and implementation updates

* seed updates

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* rspec fixes on query

* changing rspec lever test to use nonpriority method call

* updated variable name

* skipped flaky test

* fix method naming

* refactored age_of_n_nonpriority method

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

* updates to age_of_n_oldest_nonpriority method

* updates to fixx issue on lever set to infinite

* replaced num with judge.vacols_attorney_id

* rubocop fixes

* spec and update on missing parenthesis

* lint error

* seed adjustments

* compiled updates to seed

* removed repeating methods and rearranged methods

* lint fix

* adjustments to seeds

* seed updates

* seed updates

---------

Co-authored-by: Calvin <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>

* SeanP/APPEALS-55085: Add columns to distribution_stats for new AOJ legacy docket (#22655)

* aoj_legacy_stats and aoj_legacy_priority_stats to distribution_stats table, including tests

* run make migrate to drop unnecessary local table

* add distribtuion stats to serializer in lower environments (#22559)

* Calvin/appeals 53978 (#22612)

* initial code changes + rspec fixes

* lint fixes and reorganized code

* added a skip to aoj_legacy distribution stats (must add back later)

* fixed remaining rspecs by adding to stats

* lint fix

* removing guard clauses

* removed flaky test

* Update dist controller tests for addition of distribution_stats to the serializer

* Initial commit of Affinity_date_count (#22609)

* Initial commit of Affinity_date_count

* added code in aoj legacy docket

* affinity_date_count methods for legacy docket and aoj legacy docket

* addressed comments

* refactored affinity_date_count methods and added filters

* Added rspecs and code refator

* robocop fixed

* Addressed comments and updated test cases

* Lint issue fixed

* Initial commit of Affinity_date_count

* added code in aoj legacy docket

* affinity_date_count methods for legacy docket and aoj legacy docket

* addressed comments

* refactored affinity_date_count methods and added filters

* Added rspecs and code refator

* robocop fixed

* Addressed comments and updated test cases

* Lint issue fixed

* Updated in and out affinity date window for both aoj and non aoj

* Addressed comments

* Fixed lint issue

* refactored affinity date count logic and rspecs

* fixed priority and non priority  affinity count query + rspecs

* lint issue fixed

* fixed nonpriority affinity date count method

* added comments + new method for nonpriority

---------

Co-authored-by: Calvin <[email protected]>

* APPEALS-55609: Cache case distribution lever values at beginning of PPJ or other distribution (#22654)

* method additions for cache writeouts

* moved cache methods to distribution.rb

* updates to the imp.

* added conditional on assignment

* changed order of conditional

* rspec addition & revised expiration for cache

* updates to point of method call

* updates to cache imp.

* modified removal and name of cache

* updates following review

* update to rspec

* chained rspec method to call original

* rspec fixes for aoj_case_docket

* chained method count to receive

* cleared cache on case docket spec

* fix case factory defining correspondent twice

* Calvin/appeals 57225 (#22777)

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

* add check for hearing date to levers being infinite

* fix lint

* adding method to aoj case docket

* updated rspecs

* added cache clearing

* refactored spec tests

* fixed rspec expectations

* fixed use of double update

---------

Co-authored-by: Craig Reese <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* Migrate databases after Rails upgrade

* APPEALS-57350, APPEALS-57391: Fix distribution statistics affinity_date_count methods (#22955)

* add metabase to m1 docker compose

* rename metabase container and specify a version

* add script for initial metabase setup

* script output formatting

* add metabase directory

* move to a dockerfile, implement VACOLS to setup script

* add metabase to original docker-compose

* add step to initialize metabase in demo startup

* update demo startup.sh to initialize metabase with absolute path

* add make command for local metabase setup

* fix makefile syntax error

* update scripts to work in AWS

* update demo script to use apt-get instead of yum

* update demo script to use dns for vacols-db

* fix vacols DB docker DNS name

* Distribution stats error (#22773)

* Distribution stats error

* Added test cases affinity date count

* Addressed comments and refactor genpop_by_affinity_start_date method using the OR condition

* Addressed comments

* add distribtuion stats to serializer in lower environments

---------

Co-authored-by: Craig Reese <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* APPEALS-57391: Distribution statistics method affinity_date_count does not return accurate counts for the Hearing docket (#22827)

* added method for method chaining onto scope

* chained to scope

* updated affinity_date_count method and added rspec

* added missed 'self'

* changes for pasaing test

* updates to spec and affinity_date_count

* test updates

* rubocop fixes

* rubocop fixes

* removed unused methods

---------

Co-authored-by: Craig Reese <[email protected]>

* Update test files for combining the branches

---------

Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Isaiah Saucedo <[email protected]>

* Fixed appeals ready for distribution query when no prev_deciding_judge exists

* rebased hotfix/APPEALS-58200 changes to feature branch (#23067)

* rebased hotfix/APPEALS-58200 changes to feature branch

* added aoj_case_docket changes

* updated docket coordinator spec to include levers

* Update ReturnLegacyAppealsToBoardJob to use AojLegacyDocket (#22975)

* tie return_legacy_appeals_to_board_job to AojLegacyDockets

* remove duplicate test

* testing aoj case docket appeals

* Rails logger

* getting legacy_aoj_appeal tests to work

* select PREV_TYPE_ACTION

* remove Rails logger

* change constant in self.ready_to_distribute_appeals to include hearing judge

* APPEALS-60079: Hearing held before most recent Remand Judge distributing correctly when lever is set to infinite (#23115)

* update infinite lever checks to use deciding instead of hearing judge

* fix bug in seed data with user css_id lengths

* Craig/appeals 60680 (#23177)

* add test scenario and update assertions for SMR changes

* update test assertions for hearing after decision checks

* code change for tying cases with a nil previous deciding judge

* updated seed veteran names for new scenarios

* Add checks for disable_legacy Case Distribution Levers to the AOJ legacy docket

* APPEALS-61180: Improve Performance of the AOJ Distribution Queries (#23268)

* add feature toggles to AMA statistics to allow disabling of certain queries

* set case_docket counts method to only count if the appeal is not a post remand

* refactor affinity filters for performance

* refactor cavc filters in case_docket for performance

* fix rubocop warnings

* refactor for reduce repetition

* refactor repeated code in affinity filters to a common method

* fix rubocop warnings in case docket files

* update code comments for consistency in methods

* add test for distribution stats behavior with disable stats toggles turned on

* add automated test to validate new feature toggle behavior

* update tests for .counts_by_priority_and_readiness

* add comment to case docket spec

* Add new feature toggle to local/demo disable list

* remove distribution stats generation from the initial transaction to reduce time for users to get their cases

* add aoj to aoj repository metrics logs

---------

Co-authored-by: calvincostaBAH <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Calvin <[email protected]>
Co-authored-by: seanrpa <[email protected]>
Co-authored-by: Isaiah Saucedo <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Sean Parker <[email protected]>
sbashamoni added a commit that referenced this pull request Oct 30, 2024
* Feature/APPEALS-46624-react-upgrade-release (#23352)

* Poulter/appeals 46624 react 18 upgrade final (#23333)

* react 18 test upgrade

* styled-components

* EditPOAInformation test refactor, in progrss NonratingRIUModal test

* additional tests refactored

* Refactors Enzyme -> RTL

* more changes

* Enzyme -> RTL refactors (cont)

* Enzyme -> RTL refactor (cont)

* Enzyme -> RTL refactor (cont)

* Enzyme -> RTL refactor (cont)

* Enzyme -> RTL refactor (cont)

* Cherry-picking from v2 branch --cont

* fixed badge test

* Enzyme -> RTL (establishClaim-test)

* Enzyme -> RTL (cont, Batch 3)

* Batch 3 refactor cont

* Batch 3 In Progress

* Batch 3 to review

* Batch 4 updates

* ScheduleVeteran.test refactor finished

* Batch 4 and cleanups

* Batch 4 continued

* Outstanding Enzyme -> RTL refactors

* batch 4 changes and non used enzyme test removal

* clean up

* snapshot and failing test clean up

* Test updates and Snapshot fixes

* Package updates with a couple fixed tests

* Make test less brittle

* switch to for...of instead of forEach to fix async problems

* remove unnecessary
import

* lint fixes

* disable linters

* APPEALS-55525: Disable tests for seed files and lock Chrome version to v127 in Github Actions (#22567)

* add exclude pattern to github actions rspec command

* add test file exclude pattern constant

* lock chrome version to 127.0.6533.119

* React Dependency upgrade

* force wepback-bundle.js

* Fix for bva_dispatch_return_flow_spec

* fixed spec method to click pdf

* Fixed task_queue_spec.rb

* add indicated_for_contested_claims flag to legacy appeals

* update legacy appeal spec

* fix for scm_judge_assignment_spec.rb

* force state update

* fixed admin_ui_spec.rb

* fixed user_organization_spec.rb

* flow modal refactor to functional component and fix state renders, remove null saveSuccessful

* fixed motion_to_vacate_spec.rb

* revert changes

* revert all changes

* stop letting null pass

* revert more changes

* test null condition

* comment

* revert test

* add flushsync

* remove enzyme and update snapshots

* fixed EmailConfirmationModal.test.js

* fixed NonratingRequestIssueModal-test.js

* fixed Timezone.test.js

* fixed ScheduleVeteranForm.test.js

* fixed HearingTime.test.js

* fixed IssueTags.test.js

* linting

* updated daily_docket_spec.rb

* fix duplicated code for code climate

* fix more shared test setup

* hopefully the last duplicate code

* remove sleeps

* update for daily_docket_spec.rb

* add flush sync and add initialState back in

* added waits to vso_change_hearing_request_type_spec.rb

* remove legacy appeal flag

* Remove debugging statement

* revert change spec and fix state sync

* remove file changes

* fix snapshot

* Merge branch 'main' into Poulter/46624-react-18-upgrade-1

* fixed tests

* revert unnecesarry change

* remove old spec changes

* fix syncable job

* update ftk reference

* snapshot fix

---------

Co-authored-by: Griffin Dooley <[email protected]>
Co-authored-by: AdamShawBAH <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* cashflow-frontend-toolkit commit hash updated

* updated yarn.lock

---------

Co-authored-by: hawkespoulterva <[email protected]>
Co-authored-by: Griffin Dooley <[email protected]>
Co-authored-by: AdamShawBAH <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* APPEALS-25418: AOJ Remand Returned Legacy Appeals (#23294)

* 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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>

* 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 <[email protected]>

* 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

* 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-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)

* Fix rubocop and tests (#22231)

* APPEALS-52222: Add seed data file for AOJ remand return feature development (#22245)

* added initial seed file

* refactor create_correspondent

* 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 <[email protected]>

* Combination/appeals 50951 50966 50980 (#22250)

* [APPEALS-50951]: Class Created for LegacyAojDocket

* draft PR

* aoj_case_docket initial work

* initial aoj case docket creation

* added missing method to aoj_case_docket

* updated legacy docket spec to remove any AOJ data

* fixed lint error

* moving aoj appeal repository file to the correct folder

* set up aoj Appeal Repository file

* remove unnecessary rubocop disable

* LegacyAojDocket

* rspec for aoj appeal repository

* updated push_priority_appeals_to_judges_job_spec.rb

* remove byebug

* fixing some rubocop errors

* fixed aoj_legacy_docket_spec

* fixed most errors in push_priority_to_judges_job_spec

* rubocop ignores/fixes

* Added count code in aoj legacy docket

* fixed last push_priority spec error

* removed unnecessary methods and reworked rspecs

* fix update_appeal_affinity method for both CaseDocket and AojCaseDocket

* remove unneccessary code

* remove duplicate methods

* resolved comments

* removed unwanted code

* remove age_of_n_oldest_genpop_priority_appeals from aoj

* removed bfhines mentions

* remove bfhines from update_appeal_affinity_dates_query

* remove bfhines testing from rspec

---------

Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Sean Parker <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* Update admin_ui_spec.rb for CAVC levers being enabled

* Appeals-43900: Update Distribution Levers Seed Values to Enable in UI (#22249)

* init. commit

* updated test with data staged

* updates to test implementation

* removed rspec factory declarations

* removed blank space

* updated seed values for aoj seeds

* updated tests

* seeds typo

* seeds typo

* added passing class methods

* review response + updates to spec

* updated name error

* updated context name

* lint fixes

* APPEALS-50870: Add New Factory Trait to VACOLS/ Case for AOJ w/ Previous Appeal (#22248)

* add legacy_aoj_appeal factory

* add tests to vacols/case model for aoj appeal factory

* add comments to factory

* kick tests

* skip flaky distribution_spec.rb tests

* update appeals ready to distribute CSV query for AOJ docket

* update admin_ui tests for AOJ levers being enabled

* Combination/appeals 43899 43901 43902 (#22429)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* added lever to related rspecs

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* skip flaky test

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

---------

Co-authored-by: Calvin <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>

* 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

* rspec addition for aoj (#22405)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* rspec addition for aoj

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* aoj affinity lever imp.

* added lever to related rspecs

* seeds

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* update to add lever to all related rspecs

* update JOIN_PREVIOUS_APPEALS constant

* skip flaky test

* lint fixes, spec fixes, and implementation updates

* seed updates

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* rspec fixes on query

* changing rspec lever test to use nonpriority method call

* updated variable name

* skipped flaky test

* fix method naming

* refactored age_of_n_nonpriority method

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

* updates to age_of_n_oldest_nonpriority method

* updates to fixx issue on lever set to infinite

* replaced num with judge.vacols_attorney_id

* rubocop fixes

* spec and update on missing parenthesis

* lint error

---------

Co-authored-by: Calvin <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* Update testing CSV files with affinity start date and original judge columns (#22498)

* affinity start date column

* original judges column for legacy and ama appeals

* remove unnecessary rubocop disable

* swap judge_mem_id with original_judge variables for better clarity

* Calvin/appeals 53712 (#22490)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* added lever to related rspecs

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* skip flaky test

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

* aoj_cavc seed data for testing

* made changes based on craigs comments

* fixed small name issues

* lint fix

---------

Co-authored-by: samasudhirreddy <[email protected]>

* Seed Data for Testing AOJ AOD Affinity Lever (#22501)

* Seed Data for Testing AOJ AOD Affinity Lever

* Name changes to Genpop

* fixed lint issue and addressed comments

* typo error fixed

* uncommented code

* Added back 2 additional appeals with Cavc

* Isaiah/appeals 43895 (#22536)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* rspec addition for aoj

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* aoj affinity lever imp.

* added lever to related rspecs

* seeds

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* update to add lever to all related rspecs

* update JOIN_PREVIOUS_APPEALS constant

* skip flaky test

* lint fixes, spec fixes, and implementation updates

* seed updates

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* rspec fixes on query

* changing rspec lever test to use nonpriority method call

* updated variable name

* skipped flaky test

* fix method naming

* refactored age_of_n_nonpriority method

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

* updates to age_of_n_oldest_nonpriority method

* updates to fixx issue on lever set to infinite

* replaced num with judge.vacols_attorney_id

* rubocop fixes

* spec and update on missing parenthesis

* lint error

* seed adjustments

* compiled updates to seed

* removed repeating methods and rearranged methods

* lint fix

* adjustments to seeds

* seed updates

* seed updates

---------

Co-authored-by: Calvin <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>

* SeanP/APPEALS-55085: Add columns to distribution_stats for new AOJ legacy docket (#22655)

* aoj_legacy_stats and aoj_legacy_priority_stats to distribution_stats table, including tests

* run make migrate to drop unnecessary local table

* add distribtuion stats to serializer in lower environments (#22559)

* Calvin/appeals 53978 (#22612)

* initial code changes + rspec fixes

* lint fixes and reorganized code

* added a skip to aoj_legacy distribution stats (must add back later)

* fixed remaining rspecs by adding to stats

* lint fix

* removing guard clauses

* removed flaky test

* Update dist controller tests for addition of distribution_stats to the serializer

* Initial commit of Affinity_date_count (#22609)

* Initial commit of Affinity_date_count

* added code in aoj legacy docket

* affinity_date_count methods for legacy docket and aoj legacy docket

* addressed comments

* refactored affinity_date_count methods and added filters

* Added rspecs and code refator

* robocop fixed

* Addressed comments and updated test cases

* Lint issue fixed

* Initial commit of Affinity_date_count

* added code in aoj legacy docket

* affinity_date_count methods for legacy docket and aoj legacy docket

* addressed comments

* refactored affinity_date_count methods and added filters

* Added rspecs and code refator

* robocop fixed

* Addressed comments and updated test cases

* Lint issue fixed

* Updated in and out affinity date window for both aoj and non aoj

* Addressed comments

* Fixed lint issue

* refactored affinity date count logic and rspecs

* fixed priority and non priority  affinity count query + rspecs

* lint issue fixed

* fixed nonpriority affinity date count method

* added comments + new method for nonpriority

---------

Co-authored-by: Calvin <[email protected]>

* APPEALS-55609: Cache case distribution lever values at beginning of PPJ or other distribution (#22654)

* method additions for cache writeouts

* moved cache methods to distribution.rb

* updates to the imp.

* added conditional on assignment

* changed order of conditional

* rspec addition & revised expiration for cache

* updates to point of method call

* updates to cache imp.

* modified removal and name of cache

* updates following review

* update to rspec

* chained rspec method to call original

* rspec fixes for aoj_case_docket

* chained method count to receive

* cleared cache on case docket spec

* fix case factory defining correspondent twice

* Calvin/appeals 57225 (#22777)

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

* add check for hearing date to levers being infinite

* fix lint

* adding method to aoj case docket

* updated rspecs

* added cache clearing

* refactored spec tests

* fixed rspec expectations

* fixed use of double update

---------

Co-authored-by: Craig Reese <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* Migrate databases after Rails upgrade

* APPEALS-57350, APPEALS-57391: Fix distribution statistics affinity_date_count methods (#22955)

* add metabase to m1 docker compose

* rename metabase container and specify a version

* add script for initial metabase setup

* script output formatting

* add metabase directory

* move to a dockerfile, implement VACOLS to setup script

* add metabase to original docker-compose

* add step to initialize metabase in demo startup

* update demo startup.sh to initialize metabase with absolute path

* add make command for local metabase setup

* fix makefile syntax error

* update scripts to work in AWS

* update demo script to use apt-get instead of yum

* update demo script to use dns for vacols-db

* fix vacols DB docker DNS name

* Distribution stats error (#22773)

* Distribution stats error

* Added test cases affinity date count

* Addressed comments and refactor genpop_by_affinity_start_date method using the OR condition

* Addressed comments

* add distribtuion stats to serializer in lower environments

---------

Co-authored-by: Craig Reese <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* APPEALS-57391: Distribution statistics method affinity_date_count does not return accurate counts for the Hearing docket (#22827)

* added method for method chaining onto scope

* chained to scope

* updated affinity_date_count method and added rspec

* added missed 'self'

* changes for pasaing test

* updates to spec and affinity_date_count

* test updates

* rubocop fixes

* rubocop fixes

* removed unused methods

---------

Co-authored-by: Craig Reese <[email protected]>

* Update test files for combining the branches

---------

Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Isaiah Saucedo <[email protected]>

* Fixed appeals ready for distribution query when no prev_deciding_judge exists

* rebased hotfix/APPEALS-58200 changes to feature branch (#23067)

* rebased hotfix/APPEALS-58200 changes to feature branch

* added aoj_case_docket changes

* updated docket coordinator spec to include levers

* Update ReturnLegacyAppealsToBoardJob to use AojLegacyDocket (#22975)

* tie return_legacy_appeals_to_board_job to AojLegacyDockets

* remove duplicate test

* testing aoj case docket appeals

* Rails logger

* getting legacy_aoj_appeal tests to work

* select PREV_TYPE_ACTION

* remove Rails logger

* change constant in self.ready_to_distribute_appeals to include hearing judge

* APPEALS-60079: Hearing held before most recent Remand Judge distributing correctly when lever is set to infinite (#23115)

* update infinite lever checks to use deciding instead of hearing judge

* fix bug in seed data with user css_id lengths

* Craig/appeals 60680 (#23177)

* add test scenario and update assertions for SMR changes

* update test assertions for hearing after decision checks

* code change for tying cases with a nil previous deciding judge

* updated seed veteran names for new scenarios

* Add checks for disable_legacy Case Distribution Levers to the AOJ legacy docket

* APPEALS-61180: Improve Performance of the AOJ Distribution Queries (#23268)

* add feature toggles to AMA statistics to allow disabling of certain queries

* set case_docket counts method to only count if the appeal is not a post remand

* refactor affinity filters for performance

* refactor cavc filters in case_docket for performance

* fix rubocop warnings

* refactor for reduce repetition

* refactor repeated code in affinity filters to a common method

* fix rubocop warnings in case docket files

* update code comments for consistency in methods

* add test for distribution stats behavior with disable stats toggles turned on

* add automated test to validate new feature toggle behavior

* update tests for .counts_by_priority_and_readiness

* add comment to case docket spec

* Add new feature toggle to local/demo disable list

* remove distribution stats generation from the initial transaction to reduce time for users to get their cases

* add aoj to aoj repository metrics logs

---------

Co-authored-by: calvincostaBAH <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Calvin <[email protected]>
Co-authored-by: seanrpa <[email protected]>
Co-authored-by: Isaiah Saucedo <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Sean Parker <[email protected]>

* Update VACOLS case factory sequence to remove leading zeroes (#23366)

* Hotfix/appeals 62986: Fix RemandDtaOrDooHigherLevelReview script

---------

Co-authored-by: sbashamoni <[email protected]>
Co-authored-by: hawkespoulterva <[email protected]>
Co-authored-by: Griffin Dooley <[email protected]>
Co-authored-by: AdamShawBAH <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Calvin <[email protected]>
Co-authored-by: seanrpa <[email protected]>
Co-authored-by: Isaiah Saucedo <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Sean Parker <[email protected]>
Co-authored-by: Ron Wabukenda <[email protected]>
drew-hadley pushed a commit that referenced this pull request Nov 6, 2024
* Feature/APPEALS-46624-react-upgrade-release (#23352)

* Poulter/appeals 46624 react 18 upgrade final (#23333)

* react 18 test upgrade

* styled-components

* EditPOAInformation test refactor, in progrss NonratingRIUModal test

* additional tests refactored

* Refactors Enzyme -> RTL

* more changes

* Enzyme -> RTL refactors (cont)

* Enzyme -> RTL refactor (cont)

* Enzyme -> RTL refactor (cont)

* Enzyme -> RTL refactor (cont)

* Enzyme -> RTL refactor (cont)

* Cherry-picking from v2 branch --cont

* fixed badge test

* Enzyme -> RTL (establishClaim-test)

* Enzyme -> RTL (cont, Batch 3)

* Batch 3 refactor cont

* Batch 3 In Progress

* Batch 3 to review

* Batch 4 updates

* ScheduleVeteran.test refactor finished

* Batch 4 and cleanups

* Batch 4 continued

* Outstanding Enzyme -> RTL refactors

* batch 4 changes and non used enzyme test removal

* clean up

* snapshot and failing test clean up

* Test updates and Snapshot fixes

* Package updates with a couple fixed tests

* Make test less brittle

* switch to for...of instead of forEach to fix async problems

* remove unnecessary
import

* lint fixes

* disable linters

* APPEALS-55525: Disable tests for seed files and lock Chrome version to v127 in Github Actions (#22567)

* add exclude pattern to github actions rspec command

* add test file exclude pattern constant

* lock chrome version to 127.0.6533.119

* React Dependency upgrade

* force wepback-bundle.js

* Fix for bva_dispatch_return_flow_spec

* fixed spec method to click pdf

* Fixed task_queue_spec.rb

* add indicated_for_contested_claims flag to legacy appeals

* update legacy appeal spec

* fix for scm_judge_assignment_spec.rb

* force state update

* fixed admin_ui_spec.rb

* fixed user_organization_spec.rb

* flow modal refactor to functional component and fix state renders, remove null saveSuccessful

* fixed motion_to_vacate_spec.rb

* revert changes

* revert all changes

* stop letting null pass

* revert more changes

* test null condition

* comment

* revert test

* add flushsync

* remove enzyme and update snapshots

* fixed EmailConfirmationModal.test.js

* fixed NonratingRequestIssueModal-test.js

* fixed Timezone.test.js

* fixed ScheduleVeteranForm.test.js

* fixed HearingTime.test.js

* fixed IssueTags.test.js

* linting

* updated daily_docket_spec.rb

* fix duplicated code for code climate

* fix more shared test setup

* hopefully the last duplicate code

* remove sleeps

* update for daily_docket_spec.rb

* add flush sync and add initialState back in

* added waits to vso_change_hearing_request_type_spec.rb

* remove legacy appeal flag

* Remove debugging statement

* revert change spec and fix state sync

* remove file changes

* fix snapshot

* Merge branch 'main' into Poulter/46624-react-18-upgrade-1

* fixed tests

* revert unnecesarry change

* remove old spec changes

* fix syncable job

* update ftk reference

* snapshot fix

---------

Co-authored-by: Griffin Dooley <[email protected]>
Co-authored-by: AdamShawBAH <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* cashflow-frontend-toolkit commit hash updated

* updated yarn.lock

---------

Co-authored-by: hawkespoulterva <[email protected]>
Co-authored-by: Griffin Dooley <[email protected]>
Co-authored-by: AdamShawBAH <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* APPEALS-25418: AOJ Remand Returned Legacy Appeals (#23294)

* 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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>

* 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 <[email protected]>

* 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

* 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-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)

* Fix rubocop and tests (#22231)

* APPEALS-52222: Add seed data file for AOJ remand return feature development (#22245)

* added initial seed file

* refactor create_correspondent

* 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 <[email protected]>

* Combination/appeals 50951 50966 50980 (#22250)

* [APPEALS-50951]: Class Created for LegacyAojDocket

* draft PR

* aoj_case_docket initial work

* initial aoj case docket creation

* added missing method to aoj_case_docket

* updated legacy docket spec to remove any AOJ data

* fixed lint error

* moving aoj appeal repository file to the correct folder

* set up aoj Appeal Repository file

* remove unnecessary rubocop disable

* LegacyAojDocket

* rspec for aoj appeal repository

* updated push_priority_appeals_to_judges_job_spec.rb

* remove byebug

* fixing some rubocop errors

* fixed aoj_legacy_docket_spec

* fixed most errors in push_priority_to_judges_job_spec

* rubocop ignores/fixes

* Added count code in aoj legacy docket

* fixed last push_priority spec error

* removed unnecessary methods and reworked rspecs

* fix update_appeal_affinity method for both CaseDocket and AojCaseDocket

* remove unneccessary code

* remove duplicate methods

* resolved comments

* removed unwanted code

* remove age_of_n_oldest_genpop_priority_appeals from aoj

* removed bfhines mentions

* remove bfhines from update_appeal_affinity_dates_query

* remove bfhines testing from rspec

---------

Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Sean Parker <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* Update admin_ui_spec.rb for CAVC levers being enabled

* Appeals-43900: Update Distribution Levers Seed Values to Enable in UI (#22249)

* init. commit

* updated test with data staged

* updates to test implementation

* removed rspec factory declarations

* removed blank space

* updated seed values for aoj seeds

* updated tests

* seeds typo

* seeds typo

* added passing class methods

* review response + updates to spec

* updated name error

* updated context name

* lint fixes

* APPEALS-50870: Add New Factory Trait to VACOLS/ Case for AOJ w/ Previous Appeal (#22248)

* add legacy_aoj_appeal factory

* add tests to vacols/case model for aoj appeal factory

* add comments to factory

* kick tests

* skip flaky distribution_spec.rb tests

* update appeals ready to distribute CSV query for AOJ docket

* update admin_ui tests for AOJ levers being enabled

* Combination/appeals 43899 43901 43902 (#22429)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* added lever to related rspecs

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* skip flaky test

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

---------

Co-authored-by: Calvin <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>

* 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

* rspec addition for aoj (#22405)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* rspec addition for aoj

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* aoj affinity lever imp.

* added lever to related rspecs

* seeds

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* update to add lever to all related rspecs

* update JOIN_PREVIOUS_APPEALS constant

* skip flaky test

* lint fixes, spec fixes, and implementation updates

* seed updates

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* rspec fixes on query

* changing rspec lever test to use nonpriority method call

* updated variable name

* skipped flaky test

* fix method naming

* refactored age_of_n_nonpriority method

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

* updates to age_of_n_oldest_nonpriority method

* updates to fixx issue on lever set to infinite

* replaced num with judge.vacols_attorney_id

* rubocop fixes

* spec and update on missing parenthesis

* lint error

---------

Co-authored-by: Calvin <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* Update testing CSV files with affinity start date and original judge columns (#22498)

* affinity start date column

* original judges column for legacy and ama appeals

* remove unnecessary rubocop disable

* swap judge_mem_id with original_judge variables for better clarity

* Calvin/appeals 53712 (#22490)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* added lever to related rspecs

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* skip flaky test

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

* aoj_cavc seed data for testing

* made changes based on craigs comments

* fixed small name issues

* lint fix

---------

Co-authored-by: samasudhirreddy <[email protected]>

* Seed Data for Testing AOJ AOD Affinity Lever (#22501)

* Seed Data for Testing AOJ AOD Affinity Lever

* Name changes to Genpop

* fixed lint issue and addressed comments

* typo error fixed

* uncommented code

* Added back 2 additional appeals with Cavc

* Isaiah/appeals 43895 (#22536)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* rspec addition for aoj

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* aoj affinity lever imp.

* added lever to related rspecs

* seeds

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* update to add lever to all related rspecs

* update JOIN_PREVIOUS_APPEALS constant

* skip flaky test

* lint fixes, spec fixes, and implementation updates

* seed updates

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* rspec fixes on query

* changing rspec lever test to use nonpriority method call

* updated variable name

* skipped flaky test

* fix method naming

* refactored age_of_n_nonpriority method

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

* updates to age_of_n_oldest_nonpriority method

* updates to fixx issue on lever set to infinite

* replaced num with judge.vacols_attorney_id

* rubocop fixes

* spec and update on missing parenthesis

* lint error

* seed adjustments

* compiled updates to seed

* removed repeating methods and rearranged methods

* lint fix

* adjustments to seeds

* seed updates

* seed updates

---------

Co-authored-by: Calvin <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>

* SeanP/APPEALS-55085: Add columns to distribution_stats for new AOJ legacy docket (#22655)

* aoj_legacy_stats and aoj_legacy_priority_stats to distribution_stats table, including tests

* run make migrate to drop unnecessary local table

* add distribtuion stats to serializer in lower environments (#22559)

* Calvin/appeals 53978 (#22612)

* initial code changes + rspec fixes

* lint fixes and reorganized code

* added a skip to aoj_legacy distribution stats (must add back later)

* fixed remaining rspecs by adding to stats

* lint fix

* removing guard clauses

* removed flaky test

* Update dist controller tests for addition of distribution_stats to the serializer

* Initial commit of Affinity_date_count (#22609)

* Initial commit of Affinity_date_count

* added code in aoj legacy docket

* affinity_date_count methods for legacy docket and aoj legacy docket

* addressed comments

* refactored affinity_date_count methods and added filters

* Added rspecs and code refator

* robocop fixed

* Addressed comments and updated test cases

* Lint issue fixed

* Initial commit of Affinity_date_count

* added code in aoj legacy docket

* affinity_date_count methods for legacy docket and aoj legacy docket

* addressed comments

* refactored affinity_date_count methods and added filters

* Added rspecs and code refator

* robocop fixed

* Addressed comments and updated test cases

* Lint issue fixed

* Updated in and out affinity date window for both aoj and non aoj

* Addressed comments

* Fixed lint issue

* refactored affinity date count logic and rspecs

* fixed priority and non priority  affinity count query + rspecs

* lint issue fixed

* fixed nonpriority affinity date count method

* added comments + new method for nonpriority

---------

Co-authored-by: Calvin <[email protected]>

* APPEALS-55609: Cache case distribution lever values at beginning of PPJ or other distribution (#22654)

* method additions for cache writeouts

* moved cache methods to distribution.rb

* updates to the imp.

* added conditional on assignment

* changed order of conditional

* rspec addition & revised expiration for cache

* updates to point of method call

* updates to cache imp.

* modified removal and name of cache

* updates following review

* update to rspec

* chained rspec method to call original

* rspec fixes for aoj_case_docket

* chained method count to receive

* cleared cache on case docket spec

* fix case factory defining correspondent twice

* Calvin/appeals 57225 (#22777)

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

* add check for hearing date to levers being infinite

* fix lint

* adding method to aoj case docket

* updated rspecs

* added cache clearing

* refactored spec tests

* fixed rspec expectations

* fixed use of double update

---------

Co-authored-by: Craig Reese <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* Migrate databases after Rails upgrade

* APPEALS-57350, APPEALS-57391: Fix distribution statistics affinity_date_count methods (#22955)

* add metabase to m1 docker compose

* rename metabase container and specify a version

* add script for initial metabase setup

* script output formatting

* add metabase directory

* move to a dockerfile, implement VACOLS to setup script

* add metabase to original docker-compose

* add step to initialize metabase in demo startup

* update demo startup.sh to initialize metabase with absolute path

* add make command for local metabase setup

* fix makefile syntax error

* update scripts to work in AWS

* update demo script to use apt-get instead of yum

* update demo script to use dns for vacols-db

* fix vacols DB docker DNS name

* Distribution stats error (#22773)

* Distribution stats error

* Added test cases affinity date count

* Addressed comments and refactor genpop_by_affinity_start_date method using the OR condition

* Addressed comments

* add distribtuion stats to serializer in lower environments

---------

Co-authored-by: Craig Reese <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* APPEALS-57391: Distribution statistics method affinity_date_count does not return accurate counts for the Hearing docket (#22827)

* added method for method chaining onto scope

* chained to scope

* updated affinity_date_count method and added rspec

* added missed 'self'

* changes for pasaing test

* updates to spec and affinity_date_count

* test updates

* rubocop fixes

* rubocop fixes

* removed unused methods

---------

Co-authored-by: Craig Reese <[email protected]>

* Update test files for combining the branches

---------

Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Isaiah Saucedo <[email protected]>

* Fixed appeals ready for distribution query when no prev_deciding_judge exists

* rebased hotfix/APPEALS-58200 changes to feature branch (#23067)

* rebased hotfix/APPEALS-58200 changes to feature branch

* added aoj_case_docket changes

* updated docket coordinator spec to include levers

* Update ReturnLegacyAppealsToBoardJob to use AojLegacyDocket (#22975)

* tie return_legacy_appeals_to_board_job to AojLegacyDockets

* remove duplicate test

* testing aoj case docket appeals

* Rails logger

* getting legacy_aoj_appeal tests to work

* select PREV_TYPE_ACTION

* remove Rails logger

* change constant in self.ready_to_distribute_appeals to include hearing judge

* APPEALS-60079: Hearing held before most recent Remand Judge distributing correctly when lever is set to infinite (#23115)

* update infinite lever checks to use deciding instead of hearing judge

* fix bug in seed data with user css_id lengths

* Craig/appeals 60680 (#23177)

* add test scenario and update assertions for SMR changes

* update test assertions for hearing after decision checks

* code change for tying cases with a nil previous deciding judge

* updated seed veteran names for new scenarios

* Add checks for disable_legacy Case Distribution Levers to the AOJ legacy docket

* APPEALS-61180: Improve Performance of the AOJ Distribution Queries (#23268)

* add feature toggles to AMA statistics to allow disabling of certain queries

* set case_docket counts method to only count if the appeal is not a post remand

* refactor affinity filters for performance

* refactor cavc filters in case_docket for performance

* fix rubocop warnings

* refactor for reduce repetition

* refactor repeated code in affinity filters to a common method

* fix rubocop warnings in case docket files

* update code comments for consistency in methods

* add test for distribution stats behavior with disable stats toggles turned on

* add automated test to validate new feature toggle behavior

* update tests for .counts_by_priority_and_readiness

* add comment to case docket spec

* Add new feature toggle to local/demo disable list

* remove distribution stats generation from the initial transaction to reduce time for users to get their cases

* add aoj to aoj repository metrics logs

---------

Co-authored-by: calvincostaBAH <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Calvin <[email protected]>
Co-authored-by: seanrpa <[email protected]>
Co-authored-by: Isaiah Saucedo <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Sean Parker <[email protected]>

* Update VACOLS case factory sequence to remove leading zeroes (#23366)

* Hotfix/appeals 62986: Fix RemandDtaOrDooHigherLevelReview script

---------

Co-authored-by: sbashamoni <[email protected]>
Co-authored-by: hawkespoulterva <[email protected]>
Co-authored-by: Griffin Dooley <[email protected]>
Co-authored-by: AdamShawBAH <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Calvin <[email protected]>
Co-authored-by: seanrpa <[email protected]>
Co-authored-by: Isaiah Saucedo <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Sean Parker <[email protected]>
Co-authored-by: Ron Wabukenda <[email protected]>
sbashamoni added a commit that referenced this pull request Nov 15, 2024
* Feature/APPEALS-46624-react-upgrade-release (#23352)

* Poulter/appeals 46624 react 18 upgrade final (#23333)

* react 18 test upgrade

* styled-components

* EditPOAInformation test refactor, in progrss NonratingRIUModal test

* additional tests refactored

* Refactors Enzyme -> RTL

* more changes

* Enzyme -> RTL refactors (cont)

* Enzyme -> RTL refactor (cont)

* Enzyme -> RTL refactor (cont)

* Enzyme -> RTL refactor (cont)

* Enzyme -> RTL refactor (cont)

* Cherry-picking from v2 branch --cont

* fixed badge test

* Enzyme -> RTL (establishClaim-test)

* Enzyme -> RTL (cont, Batch 3)

* Batch 3 refactor cont

* Batch 3 In Progress

* Batch 3 to review

* Batch 4 updates

* ScheduleVeteran.test refactor finished

* Batch 4 and cleanups

* Batch 4 continued

* Outstanding Enzyme -> RTL refactors

* batch 4 changes and non used enzyme test removal

* clean up

* snapshot and failing test clean up

* Test updates and Snapshot fixes

* Package updates with a couple fixed tests

* Make test less brittle

* switch to for...of instead of forEach to fix async problems

* remove unnecessary
import

* lint fixes

* disable linters

* APPEALS-55525: Disable tests for seed files and lock Chrome version to v127 in Github Actions (#22567)

* add exclude pattern to github actions rspec command

* add test file exclude pattern constant

* lock chrome version to 127.0.6533.119

* React Dependency upgrade

* force wepback-bundle.js

* Fix for bva_dispatch_return_flow_spec

* fixed spec method to click pdf

* Fixed task_queue_spec.rb

* add indicated_for_contested_claims flag to legacy appeals

* update legacy appeal spec

* fix for scm_judge_assignment_spec.rb

* force state update

* fixed admin_ui_spec.rb

* fixed user_organization_spec.rb

* flow modal refactor to functional component and fix state renders, remove null saveSuccessful

* fixed motion_to_vacate_spec.rb

* revert changes

* revert all changes

* stop letting null pass

* revert more changes

* test null condition

* comment

* revert test

* add flushsync

* remove enzyme and update snapshots

* fixed EmailConfirmationModal.test.js

* fixed NonratingRequestIssueModal-test.js

* fixed Timezone.test.js

* fixed ScheduleVeteranForm.test.js

* fixed HearingTime.test.js

* fixed IssueTags.test.js

* linting

* updated daily_docket_spec.rb

* fix duplicated code for code climate

* fix more shared test setup

* hopefully the last duplicate code

* remove sleeps

* update for daily_docket_spec.rb

* add flush sync and add initialState back in

* added waits to vso_change_hearing_request_type_spec.rb

* remove legacy appeal flag

* Remove debugging statement

* revert change spec and fix state sync

* remove file changes

* fix snapshot

* Merge branch 'main' into Poulter/46624-react-18-upgrade-1

* fixed tests

* revert unnecesarry change

* remove old spec changes

* fix syncable job

* update ftk reference

* snapshot fix

---------

Co-authored-by: Griffin Dooley <[email protected]>
Co-authored-by: AdamShawBAH <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* cashflow-frontend-toolkit commit hash updated

* updated yarn.lock

---------

Co-authored-by: hawkespoulterva <[email protected]>
Co-authored-by: Griffin Dooley <[email protected]>
Co-authored-by: AdamShawBAH <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* APPEALS-25418: AOJ Remand Returned Legacy Appeals (#23294)

* 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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>

* 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 <[email protected]>

* 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

* 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-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)

* Fix rubocop and tests (#22231)

* APPEALS-52222: Add seed data file for AOJ remand return feature development (#22245)

* added initial seed file

* refactor create_correspondent

* 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 <[email protected]>

* Combination/appeals 50951 50966 50980 (#22250)

* [APPEALS-50951]: Class Created for LegacyAojDocket

* draft PR

* aoj_case_docket initial work

* initial aoj case docket creation

* added missing method to aoj_case_docket

* updated legacy docket spec to remove any AOJ data

* fixed lint error

* moving aoj appeal repository file to the correct folder

* set up aoj Appeal Repository file

* remove unnecessary rubocop disable

* LegacyAojDocket

* rspec for aoj appeal repository

* updated push_priority_appeals_to_judges_job_spec.rb

* remove byebug

* fixing some rubocop errors

* fixed aoj_legacy_docket_spec

* fixed most errors in push_priority_to_judges_job_spec

* rubocop ignores/fixes

* Added count code in aoj legacy docket

* fixed last push_priority spec error

* removed unnecessary methods and reworked rspecs

* fix update_appeal_affinity method for both CaseDocket and AojCaseDocket

* remove unneccessary code

* remove duplicate methods

* resolved comments

* removed unwanted code

* remove age_of_n_oldest_genpop_priority_appeals from aoj

* removed bfhines mentions

* remove bfhines from update_appeal_affinity_dates_query

* remove bfhines testing from rspec

---------

Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Sean Parker <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* Update admin_ui_spec.rb for CAVC levers being enabled

* Appeals-43900: Update Distribution Levers Seed Values to Enable in UI (#22249)

* init. commit

* updated test with data staged

* updates to test implementation

* removed rspec factory declarations

* removed blank space

* updated seed values for aoj seeds

* updated tests

* seeds typo

* seeds typo

* added passing class methods

* review response + updates to spec

* updated name error

* updated context name

* lint fixes

* APPEALS-50870: Add New Factory Trait to VACOLS/ Case for AOJ w/ Previous Appeal (#22248)

* add legacy_aoj_appeal factory

* add tests to vacols/case model for aoj appeal factory

* add comments to factory

* kick tests

* skip flaky distribution_spec.rb tests

* update appeals ready to distribute CSV query for AOJ docket

* update admin_ui tests for AOJ levers being enabled

* Combination/appeals 43899 43901 43902 (#22429)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* added lever to related rspecs

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* skip flaky test

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

---------

Co-authored-by: Calvin <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>

* 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

* rspec addition for aoj (#22405)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* rspec addition for aoj

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* aoj affinity lever imp.

* added lever to related rspecs

* seeds

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* update to add lever to all related rspecs

* update JOIN_PREVIOUS_APPEALS constant

* skip flaky test

* lint fixes, spec fixes, and implementation updates

* seed updates

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* rspec fixes on query

* changing rspec lever test to use nonpriority method call

* updated variable name

* skipped flaky test

* fix method naming

* refactored age_of_n_nonpriority method

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

* updates to age_of_n_oldest_nonpriority method

* updates to fixx issue on lever set to infinite

* replaced num with judge.vacols_attorney_id

* rubocop fixes

* spec and update on missing parenthesis

* lint error

---------

Co-authored-by: Calvin <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* Update testing CSV files with affinity start date and original judge columns (#22498)

* affinity start date column

* original judges column for legacy and ama appeals

* remove unnecessary rubocop disable

* swap judge_mem_id with original_judge variables for better clarity

* Calvin/appeals 53712 (#22490)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* added lever to related rspecs

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* skip flaky test

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

* aoj_cavc seed data for testing

* made changes based on craigs comments

* fixed small name issues

* lint fix

---------

Co-authored-by: samasudhirreddy <[email protected]>

* Seed Data for Testing AOJ AOD Affinity Lever (#22501)

* Seed Data for Testing AOJ AOD Affinity Lever

* Name changes to Genpop

* fixed lint issue and addressed comments

* typo error fixed

* uncommented code

* Added back 2 additional appeals with Cavc

* Isaiah/appeals 43895 (#22536)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* rspec addition for aoj

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* aoj affinity lever imp.

* added lever to related rspecs

* seeds

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* update to add lever to all related rspecs

* update JOIN_PREVIOUS_APPEALS constant

* skip flaky test

* lint fixes, spec fixes, and implementation updates

* seed updates

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* rspec fixes on query

* changing rspec lever test to use nonpriority method call

* updated variable name

* skipped flaky test

* fix method naming

* refactored age_of_n_nonpriority method

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

* updates to age_of_n_oldest_nonpriority method

* updates to fixx issue on lever set to infinite

* replaced num with judge.vacols_attorney_id

* rubocop fixes

* spec and update on missing parenthesis

* lint error

* seed adjustments

* compiled updates to seed

* removed repeating methods and rearranged methods

* lint fix

* adjustments to seeds

* seed updates

* seed updates

---------

Co-authored-by: Calvin <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>

* SeanP/APPEALS-55085: Add columns to distribution_stats for new AOJ legacy docket (#22655)

* aoj_legacy_stats and aoj_legacy_priority_stats to distribution_stats table, including tests

* run make migrate to drop unnecessary local table

* add distribtuion stats to serializer in lower environments (#22559)

* Calvin/appeals 53978 (#22612)

* initial code changes + rspec fixes

* lint fixes and reorganized code

* added a skip to aoj_legacy distribution stats (must add back later)

* fixed remaining rspecs by adding to stats

* lint fix

* removing guard clauses

* removed flaky test

* Update dist controller tests for addition of distribution_stats to the serializer

* Initial commit of Affinity_date_count (#22609)

* Initial commit of Affinity_date_count

* added code in aoj legacy docket

* affinity_date_count methods for legacy docket and aoj legacy docket

* addressed comments

* refactored affinity_date_count methods and added filters

* Added rspecs and code refator

* robocop fixed

* Addressed comments and updated test cases

* Lint issue fixed

* Initial commit of Affinity_date_count

* added code in aoj legacy docket

* affinity_date_count methods for legacy docket and aoj legacy docket

* addressed comments

* refactored affinity_date_count methods and added filters

* Added rspecs and code refator

* robocop fixed

* Addressed comments and updated test cases

* Lint issue fixed

* Updated in and out affinity date window for both aoj and non aoj

* Addressed comments

* Fixed lint issue

* refactored affinity date count logic and rspecs

* fixed priority and non priority  affinity count query + rspecs

* lint issue fixed

* fixed nonpriority affinity date count method

* added comments + new method for nonpriority

---------

Co-authored-by: Calvin <[email protected]>

* APPEALS-55609: Cache case distribution lever values at beginning of PPJ or other distribution (#22654)

* method additions for cache writeouts

* moved cache methods to distribution.rb

* updates to the imp.

* added conditional on assignment

* changed order of conditional

* rspec addition & revised expiration for cache

* updates to point of method call

* updates to cache imp.

* modified removal and name of cache

* updates following review

* update to rspec

* chained rspec method to call original

* rspec fixes for aoj_case_docket

* chained method count to receive

* cleared cache on case docket spec

* fix case factory defining correspondent twice

* Calvin/appeals 57225 (#22777)

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

* add check for hearing date to levers being infinite

* fix lint

* adding method to aoj case docket

* updated rspecs

* added cache clearing

* refactored spec tests

* fixed rspec expectations

* fixed use of double update

---------

Co-authored-by: Craig Reese <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* Migrate databases after Rails upgrade

* APPEALS-57350, APPEALS-57391: Fix distribution statistics affinity_date_count methods (#22955)

* add metabase to m1 docker compose

* rename metabase container and specify a version

* add script for initial metabase setup

* script output formatting

* add metabase directory

* move to a dockerfile, implement VACOLS to setup script

* add metabase to original docker-compose

* add step to initialize metabase in demo startup

* update demo startup.sh to initialize metabase with absolute path

* add make command for local metabase setup

* fix makefile syntax error

* update scripts to work in AWS

* update demo script to use apt-get instead of yum

* update demo script to use dns for vacols-db

* fix vacols DB docker DNS name

* Distribution stats error (#22773)

* Distribution stats error

* Added test cases affinity date count

* Addressed comments and refactor genpop_by_affinity_start_date method using the OR condition

* Addressed comments

* add distribtuion stats to serializer in lower environments

---------

Co-authored-by: Craig Reese <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* APPEALS-57391: Distribution statistics method affinity_date_count does not return accurate counts for the Hearing docket (#22827)

* added method for method chaining onto scope

* chained to scope

* updated affinity_date_count method and added rspec

* added missed 'self'

* changes for pasaing test

* updates to spec and affinity_date_count

* test updates

* rubocop fixes

* rubocop fixes

* removed unused methods

---------

Co-authored-by: Craig Reese <[email protected]>

* Update test files for combining the branches

---------

Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Isaiah Saucedo <[email protected]>

* Fixed appeals ready for distribution query when no prev_deciding_judge exists

* rebased hotfix/APPEALS-58200 changes to feature branch (#23067)

* rebased hotfix/APPEALS-58200 changes to feature branch

* added aoj_case_docket changes

* updated docket coordinator spec to include levers

* Update ReturnLegacyAppealsToBoardJob to use AojLegacyDocket (#22975)

* tie return_legacy_appeals_to_board_job to AojLegacyDockets

* remove duplicate test

* testing aoj case docket appeals

* Rails logger

* getting legacy_aoj_appeal tests to work

* select PREV_TYPE_ACTION

* remove Rails logger

* change constant in self.ready_to_distribute_appeals to include hearing judge

* APPEALS-60079: Hearing held before most recent Remand Judge distributing correctly when lever is set to infinite (#23115)

* update infinite lever checks to use deciding instead of hearing judge

* fix bug in seed data with user css_id lengths

* Craig/appeals 60680 (#23177)

* add test scenario and update assertions for SMR changes

* update test assertions for hearing after decision checks

* code change for tying cases with a nil previous deciding judge

* updated seed veteran names for new scenarios

* Add checks for disable_legacy Case Distribution Levers to the AOJ legacy docket

* APPEALS-61180: Improve Performance of the AOJ Distribution Queries (#23268)

* add feature toggles to AMA statistics to allow disabling of certain queries

* set case_docket counts method to only count if the appeal is not a post remand

* refactor affinity filters for performance

* refactor cavc filters in case_docket for performance

* fix rubocop warnings

* refactor for reduce repetition

* refactor repeated code in affinity filters to a common method

* fix rubocop warnings in case docket files

* update code comments for consistency in methods

* add test for distribution stats behavior with disable stats toggles turned on

* add automated test to validate new feature toggle behavior

* update tests for .counts_by_priority_and_readiness

* add comment to case docket spec

* Add new feature toggle to local/demo disable list

* remove distribution stats generation from the initial transaction to reduce time for users to get their cases

* add aoj to aoj repository metrics logs

---------

Co-authored-by: calvincostaBAH <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Calvin <[email protected]>
Co-authored-by: seanrpa <[email protected]>
Co-authored-by: Isaiah Saucedo <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Sean Parker <[email protected]>

* Update VACOLS case factory sequence to remove leading zeroes (#23366)

* Hotfix/appeals 62986: Fix RemandDtaOrDooHigherLevelReview script

---------

Co-authored-by: sbashamoni <[email protected]>
Co-authored-by: hawkespoulterva <[email protected]>
Co-authored-by: Griffin Dooley <[email protected]>
Co-authored-by: AdamShawBAH <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Calvin <[email protected]>
Co-authored-by: seanrpa <[email protected]>
Co-authored-by: Isaiah Saucedo <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Sean Parker <[email protected]>
Co-authored-by: Ron Wabukenda <[email protected]>
sbashamoni added a commit that referenced this pull request Nov 15, 2024
* Feature/APPEALS-46624-react-upgrade-release (#23352)

* Poulter/appeals 46624 react 18 upgrade final (#23333)

* react 18 test upgrade

* styled-components

* EditPOAInformation test refactor, in progrss NonratingRIUModal test

* additional tests refactored

* Refactors Enzyme -> RTL

* more changes

* Enzyme -> RTL refactors (cont)

* Enzyme -> RTL refactor (cont)

* Enzyme -> RTL refactor (cont)

* Enzyme -> RTL refactor (cont)

* Enzyme -> RTL refactor (cont)

* Cherry-picking from v2 branch --cont

* fixed badge test

* Enzyme -> RTL (establishClaim-test)

* Enzyme -> RTL (cont, Batch 3)

* Batch 3 refactor cont

* Batch 3 In Progress

* Batch 3 to review

* Batch 4 updates

* ScheduleVeteran.test refactor finished

* Batch 4 and cleanups

* Batch 4 continued

* Outstanding Enzyme -> RTL refactors

* batch 4 changes and non used enzyme test removal

* clean up

* snapshot and failing test clean up

* Test updates and Snapshot fixes

* Package updates with a couple fixed tests

* Make test less brittle

* switch to for...of instead of forEach to fix async problems

* remove unnecessary
import

* lint fixes

* disable linters

* APPEALS-55525: Disable tests for seed files and lock Chrome version to v127 in Github Actions (#22567)

* add exclude pattern to github actions rspec command

* add test file exclude pattern constant

* lock chrome version to 127.0.6533.119

* React Dependency upgrade

* force wepback-bundle.js

* Fix for bva_dispatch_return_flow_spec

* fixed spec method to click pdf

* Fixed task_queue_spec.rb

* add indicated_for_contested_claims flag to legacy appeals

* update legacy appeal spec

* fix for scm_judge_assignment_spec.rb

* force state update

* fixed admin_ui_spec.rb

* fixed user_organization_spec.rb

* flow modal refactor to functional component and fix state renders, remove null saveSuccessful

* fixed motion_to_vacate_spec.rb

* revert changes

* revert all changes

* stop letting null pass

* revert more changes

* test null condition

* comment

* revert test

* add flushsync

* remove enzyme and update snapshots

* fixed EmailConfirmationModal.test.js

* fixed NonratingRequestIssueModal-test.js

* fixed Timezone.test.js

* fixed ScheduleVeteranForm.test.js

* fixed HearingTime.test.js

* fixed IssueTags.test.js

* linting

* updated daily_docket_spec.rb

* fix duplicated code for code climate

* fix more shared test setup

* hopefully the last duplicate code

* remove sleeps

* update for daily_docket_spec.rb

* add flush sync and add initialState back in

* added waits to vso_change_hearing_request_type_spec.rb

* remove legacy appeal flag

* Remove debugging statement

* revert change spec and fix state sync

* remove file changes

* fix snapshot

* Merge branch 'main' into Poulter/46624-react-18-upgrade-1

* fixed tests

* revert unnecesarry change

* remove old spec changes

* fix syncable job

* update ftk reference

* snapshot fix

---------

Co-authored-by: Griffin Dooley <[email protected]>
Co-authored-by: AdamShawBAH <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* cashflow-frontend-toolkit commit hash updated

* updated yarn.lock

---------

Co-authored-by: hawkespoulterva <[email protected]>
Co-authored-by: Griffin Dooley <[email protected]>
Co-authored-by: AdamShawBAH <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* APPEALS-25418: AOJ Remand Returned Legacy Appeals (#23294)

* 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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>

* 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 <[email protected]>

* 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

* 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-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)

* Fix rubocop and tests (#22231)

* APPEALS-52222: Add seed data file for AOJ remand return feature development (#22245)

* added initial seed file

* refactor create_correspondent

* 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 <[email protected]>

* Combination/appeals 50951 50966 50980 (#22250)

* [APPEALS-50951]: Class Created for LegacyAojDocket

* draft PR

* aoj_case_docket initial work

* initial aoj case docket creation

* added missing method to aoj_case_docket

* updated legacy docket spec to remove any AOJ data

* fixed lint error

* moving aoj appeal repository file to the correct folder

* set up aoj Appeal Repository file

* remove unnecessary rubocop disable

* LegacyAojDocket

* rspec for aoj appeal repository

* updated push_priority_appeals_to_judges_job_spec.rb

* remove byebug

* fixing some rubocop errors

* fixed aoj_legacy_docket_spec

* fixed most errors in push_priority_to_judges_job_spec

* rubocop ignores/fixes

* Added count code in aoj legacy docket

* fixed last push_priority spec error

* removed unnecessary methods and reworked rspecs

* fix update_appeal_affinity method for both CaseDocket and AojCaseDocket

* remove unneccessary code

* remove duplicate methods

* resolved comments

* removed unwanted code

* remove age_of_n_oldest_genpop_priority_appeals from aoj

* removed bfhines mentions

* remove bfhines from update_appeal_affinity_dates_query

* remove bfhines testing from rspec

---------

Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Sean Parker <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* Update admin_ui_spec.rb for CAVC levers being enabled

* Appeals-43900: Update Distribution Levers Seed Values to Enable in UI (#22249)

* init. commit

* updated test with data staged

* updates to test implementation

* removed rspec factory declarations

* removed blank space

* updated seed values for aoj seeds

* updated tests

* seeds typo

* seeds typo

* added passing class methods

* review response + updates to spec

* updated name error

* updated context name

* lint fixes

* APPEALS-50870: Add New Factory Trait to VACOLS/ Case for AOJ w/ Previous Appeal (#22248)

* add legacy_aoj_appeal factory

* add tests to vacols/case model for aoj appeal factory

* add comments to factory

* kick tests

* skip flaky distribution_spec.rb tests

* update appeals ready to distribute CSV query for AOJ docket

* update admin_ui tests for AOJ levers being enabled

* Combination/appeals 43899 43901 43902 (#22429)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* added lever to related rspecs

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* skip flaky test

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

---------

Co-authored-by: Calvin <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>

* 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

* rspec addition for aoj (#22405)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* rspec addition for aoj

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* aoj affinity lever imp.

* added lever to related rspecs

* seeds

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* update to add lever to all related rspecs

* update JOIN_PREVIOUS_APPEALS constant

* skip flaky test

* lint fixes, spec fixes, and implementation updates

* seed updates

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* rspec fixes on query

* changing rspec lever test to use nonpriority method call

* updated variable name

* skipped flaky test

* fix method naming

* refactored age_of_n_nonpriority method

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

* updates to age_of_n_oldest_nonpriority method

* updates to fixx issue on lever set to infinite

* replaced num with judge.vacols_attorney_id

* rubocop fixes

* spec and update on missing parenthesis

* lint error

---------

Co-authored-by: Calvin <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* Update testing CSV files with affinity start date and original judge columns (#22498)

* affinity start date column

* original judges column for legacy and ama appeals

* remove unnecessary rubocop disable

* swap judge_mem_id with original_judge variables for better clarity

* Calvin/appeals 53712 (#22490)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* added lever to related rspecs

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* skip flaky test

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

* aoj_cavc seed data for testing

* made changes based on craigs comments

* fixed small name issues

* lint fix

---------

Co-authored-by: samasudhirreddy <[email protected]>

* Seed Data for Testing AOJ AOD Affinity Lever (#22501)

* Seed Data for Testing AOJ AOD Affinity Lever

* Name changes to Genpop

* fixed lint issue and addressed comments

* typo error fixed

* uncommented code

* Added back 2 additional appeals with Cavc

* Isaiah/appeals 43895 (#22536)

* initial aoj_cavc affinity lever work

* added seed data for aoj cavc lever

* initial testing for aoj_cavc

* rspec addition for aoj

* updated rspecs + seed data

* updated JOIN_PREVIOUS_APPEAL constant

* updated spec files to include aoj cavc lever + fix linting

* lint fix

* rename aoj_cavc_affinity trait

* aoj affinity lever imp.

* added lever to related rspecs

* seeds

* Added Aoj Aod affinity days in distribute appeals

* Aoj_aod affinity lever

* removed bfac stuff

* Added seed data and test cases

* fixed typo errors

* updated JOIN_PREVIOUS_APPEAL

* fix for binding query with variables

* removed altering of bfkey in the aoj_case_docket_spec test

* update lever name and add to related rspecs

* one more update for lever name

* added lever to related rspecs

* edited rspec tests

* update to add lever to all related rspecs

* update JOIN_PREVIOUS_APPEALS constant

* skip flaky test

* lint fixes, spec fixes, and implementation updates

* seed updates

* fixed query santizing with variables + added infinite lever error handling

* added tests for when both aoj levers are infinite

* rspec fixes on query

* changing rspec lever test to use nonpriority method call

* updated variable name

* skipped flaky test

* fix method naming

* refactored age_of_n_nonpriority method

* fixed parenthesis for age_of_n method

* Added 2 additional appeal with cavc

* Updated dates

* updates to age_of_n_oldest_nonpriority method

* updates to fixx issue on lever set to infinite

* replaced num with judge.vacols_attorney_id

* rubocop fixes

* spec and update on missing parenthesis

* lint error

* seed adjustments

* compiled updates to seed

* removed repeating methods and rearranged methods

* lint fix

* adjustments to seeds

* seed updates

* seed updates

---------

Co-authored-by: Calvin <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>

* SeanP/APPEALS-55085: Add columns to distribution_stats for new AOJ legacy docket (#22655)

* aoj_legacy_stats and aoj_legacy_priority_stats to distribution_stats table, including tests

* run make migrate to drop unnecessary local table

* add distribtuion stats to serializer in lower environments (#22559)

* Calvin/appeals 53978 (#22612)

* initial code changes + rspec fixes

* lint fixes and reorganized code

* added a skip to aoj_legacy distribution stats (must add back later)

* fixed remaining rspecs by adding to stats

* lint fix

* removing guard clauses

* removed flaky test

* Update dist controller tests for addition of distribution_stats to the serializer

* Initial commit of Affinity_date_count (#22609)

* Initial commit of Affinity_date_count

* added code in aoj legacy docket

* affinity_date_count methods for legacy docket and aoj legacy docket

* addressed comments

* refactored affinity_date_count methods and added filters

* Added rspecs and code refator

* robocop fixed

* Addressed comments and updated test cases

* Lint issue fixed

* Initial commit of Affinity_date_count

* added code in aoj legacy docket

* affinity_date_count methods for legacy docket and aoj legacy docket

* addressed comments

* refactored affinity_date_count methods and added filters

* Added rspecs and code refator

* robocop fixed

* Addressed comments and updated test cases

* Lint issue fixed

* Updated in and out affinity date window for both aoj and non aoj

* Addressed comments

* Fixed lint issue

* refactored affinity date count logic and rspecs

* fixed priority and non priority  affinity count query + rspecs

* lint issue fixed

* fixed nonpriority affinity date count method

* added comments + new method for nonpriority

---------

Co-authored-by: Calvin <[email protected]>

* APPEALS-55609: Cache case distribution lever values at beginning of PPJ or other distribution (#22654)

* method additions for cache writeouts

* moved cache methods to distribution.rb

* updates to the imp.

* added conditional on assignment

* changed order of conditional

* rspec addition & revised expiration for cache

* updates to point of method call

* updates to cache imp.

* modified removal and name of cache

* updates following review

* update to rspec

* chained rspec method to call original

* rspec fixes for aoj_case_docket

* chained method count to receive

* cleared cache on case docket spec

* fix case factory defining correspondent twice

* Calvin/appeals 57225 (#22777)

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

* add check for hearing date to levers being infinite

* fix lint

* adding method to aoj case docket

* updated rspecs

* added cache clearing

* refactored spec tests

* fixed rspec expectations

* fixed use of double update

---------

Co-authored-by: Craig Reese <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* Migrate databases after Rails upgrade

* APPEALS-57350, APPEALS-57391: Fix distribution statistics affinity_date_count methods (#22955)

* add metabase to m1 docker compose

* rename metabase container and specify a version

* add script for initial metabase setup

* script output formatting

* add metabase directory

* move to a dockerfile, implement VACOLS to setup script

* add metabase to original docker-compose

* add step to initialize metabase in demo startup

* update demo startup.sh to initialize metabase with absolute path

* add make command for local metabase setup

* fix makefile syntax error

* update scripts to work in AWS

* update demo script to use apt-get instead of yum

* update demo script to use dns for vacols-db

* fix vacols DB docker DNS name

* Distribution stats error (#22773)

* Distribution stats error

* Added test cases affinity date count

* Addressed comments and refactor genpop_by_affinity_start_date method using the OR condition

* Addressed comments

* add distribtuion stats to serializer in lower environments

---------

Co-authored-by: Craig Reese <[email protected]>
Co-authored-by: Craig Reese <[email protected]>

* APPEALS-57391: Distribution statistics method affinity_date_count does not return accurate counts for the Hearing docket (#22827)

* added method for method chaining onto scope

* chained to scope

* updated affinity_date_count method and added rspec

* added missed 'self'

* changes for pasaing test

* updates to spec and affinity_date_count

* test updates

* rubocop fixes

* rubocop fixes

* removed unused methods

---------

Co-authored-by: Craig Reese <[email protected]>

* Update test files for combining the branches

---------

Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Isaiah Saucedo <[email protected]>

* Fixed appeals ready for distribution query when no prev_deciding_judge exists

* rebased hotfix/APPEALS-58200 changes to feature branch (#23067)

* rebased hotfix/APPEALS-58200 changes to feature branch

* added aoj_case_docket changes

* updated docket coordinator spec to include levers

* Update ReturnLegacyAppealsToBoardJob to use AojLegacyDocket (#22975)

* tie return_legacy_appeals_to_board_job to AojLegacyDockets

* remove duplicate test

* testing aoj case docket appeals

* Rails logger

* getting legacy_aoj_appeal tests to work

* select PREV_TYPE_ACTION

* remove Rails logger

* change constant in self.ready_to_distribute_appeals to include hearing judge

* APPEALS-60079: Hearing held before most recent Remand Judge distributing correctly when lever is set to infinite (#23115)

* update infinite lever checks to use deciding instead of hearing judge

* fix bug in seed data with user css_id lengths

* Craig/appeals 60680 (#23177)

* add test scenario and update assertions for SMR changes

* update test assertions for hearing after decision checks

* code change for tying cases with a nil previous deciding judge

* updated seed veteran names for new scenarios

* Add checks for disable_legacy Case Distribution Levers to the AOJ legacy docket

* APPEALS-61180: Improve Performance of the AOJ Distribution Queries (#23268)

* add feature toggles to AMA statistics to allow disabling of certain queries

* set case_docket counts method to only count if the appeal is not a post remand

* refactor affinity filters for performance

* refactor cavc filters in case_docket for performance

* fix rubocop warnings

* refactor for reduce repetition

* refactor repeated code in affinity filters to a common method

* fix rubocop warnings in case docket files

* update code comments for consistency in methods

* add test for distribution stats behavior with disable stats toggles turned on

* add automated test to validate new feature toggle behavior

* update tests for .counts_by_priority_and_readiness

* add comment to case docket spec

* Add new feature toggle to local/demo disable list

* remove distribution stats generation from the initial transaction to reduce time for users to get their cases

* add aoj to aoj repository metrics logs

---------

Co-authored-by: calvincostaBAH <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Calvin <[email protected]>
Co-authored-by: seanrpa <[email protected]>
Co-authored-by: Isaiah Saucedo <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Sean Parker <[email protected]>

* Update VACOLS case factory sequence to remove leading zeroes (#23366)

* Hotfix/appeals 62986: Fix RemandDtaOrDooHigherLevelReview script

---------

Co-authored-by: sbashamoni <[email protected]>
Co-authored-by: hawkespoulterva <[email protected]>
Co-authored-by: Griffin Dooley <[email protected]>
Co-authored-by: AdamShawBAH <[email protected]>
Co-authored-by: calvincostaBAH <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Calvin <[email protected]>
Co-authored-by: seanrpa <[email protected]>
Co-authored-by: Isaiah Saucedo <[email protected]>
Co-authored-by: samasudhirreddy <[email protected]>
Co-authored-by: Sean Parker <[email protected]>
Co-authored-by: Ron Wabukenda <[email protected]>
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