Skip to content

Commit

Permalink
APPEALS-44916 seed data update (#22008)
Browse files Browse the repository at this point in the history
* 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-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

* 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

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

* remove unnecessarily included module from job (#21827)

* APPEALS-47211: Improve Performance of Distribution Queries (#21840)

* rework ready_for_distribution scope

* fix non-hearing docket distribution bug

* restart tests

* added null checks for appeal affinity in distribution queries, update tests (#21893)

* add check for appeal being active to distribution and associated slack message (#21902)

* prelim work on 48033

* refactored code a bit, working on data creation now

* created ama_affinity data

* fixing mispelt variable

* add back line that was removed

* updated users_spec to now pass

---------

Co-authored-by: calvincostaBAH <108481161+calvincostaBAH@users.noreply.github.com>
Co-authored-by: Isaiah Saucedo <irsaucedo5@gmail.com>
Co-authored-by: Sean Parker <Sean.Parker3@va.gov>
Co-authored-by: Calvin <Calvin.Costa@va.gov>
  • Loading branch information
5 people authored Jun 25, 2024
1 parent 470f3da commit 6ca18ab
Showing 1 changed file with 91 additions and 2 deletions.
93 changes: 91 additions & 2 deletions db/seeds/ama_affinity_cases.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def seed!
create_cda_admin_user
create_priority_affinity_cases
create_nonpriority_affinity_cases
create_set_of_affinity_cases
end

private
Expand Down Expand Up @@ -54,7 +55,7 @@ def create_cda_admin_user

def create_priority_affinity_cases
judges_with_attorneys.each do |judge|
3.times do
2.times do
create_case_ready_for_less_than_cavc_affinty_days(judge)
create_case_ready_for_less_than_aod_hearing_affinity_days(judge)
create_case_ready_for_more_than_cavc_affinty_days(judge)
Expand All @@ -65,13 +66,23 @@ def create_priority_affinity_cases

def create_nonpriority_affinity_cases
judges_with_attorneys.each do |judge|
3.times do
2.times do
create_case_ready_for_less_than_hearing_affinity_days(judge)
create_case_ready_for_more_than_hearing_affinity_days(judge)
end
end
end

def create_set_of_affinity_cases
judges_with_attorneys.each do |judge|
create_ama_affinity_cases_set(judge, (4.years + 1.week))
create_ama_affinity_cases_set(judge, 3.years)
end
2.times do
create_ama_affinity_cases_set(User.find_by_css_id("BVABDANIEL"), 1.year)
end
end

def judges_with_attorneys
# use judges with attorneys to minimize how many cases are distributed when testing because the
# alternative_batch_size is higher than the batch_size for most judge teams
Expand Down Expand Up @@ -253,6 +264,84 @@ def create_case_ready_for_more_than_aod_hearing_affinity_days(judge)

Timecop.return
end

def create_ama_affinity_cases_set(judge, years_old)
attorney = JudgeTeam.for_judge(judge).attorneys&.filter(&:attorney_in_vacols?)&.first ||
create(:user, :with_vacols_attorney_record)

Timecop.travel(years_old.ago)

direct_review_appeal = create(:appeal, :direct_review_docket, :ready_for_distribution, associated_judge: judge, veteran: create_veteran)
evidence_submission_appeal = create(:appeal, :evidence_submission_docket, :ready_for_distribution, associated_judge: judge, veteran: create_veteran)
hearing_appeal = create(:appeal, :hearing_docket, :with_post_intake_tasks, veteran: create_veteran)
hearing_aod_appeal = create(:appeal, :hearing_docket, :with_post_intake_tasks, veteran: create_veteran)

# travel to when the hearing was held, then create the held hearing and post-hearing tasks:
# add 91 days for the amount of time the post-hearing tasks are open and add 7 more to make the case ready
# for more than the hearing affinity days value
Timecop.return
Timecop.travel(92.days.ago)
create(:hearing, :held, appeal: hearing_appeal, judge: judge, adding_user: User.system_user)
create(:hearing, :held, appeal: hearing_aod_appeal, judge: judge, adding_user: User.system_user)

Timecop.travel(91.days.from_now)
hearing_appeal.tasks.where(type: AssignHearingDispositionTask.name).first.children.map(&:completed!)
hearing_aod_appeal.tasks.where(type: AssignHearingDispositionTask.name).first.children.map(&:completed!)

# created granted AOD motion to make this priority
create(:advance_on_docket_motion, appeal: hearing_aod_appeal, granted: true, person_id: hearing_aod_appeal.claimant.person.id,
reason: Constants.AOD_REASONS.financial_distress, user: User.system_user)

# set the distribution task to assigned, if it was not already
dist_task1 = hearing_appeal.tasks.where(type: DistributionTask.name).first
dist_task2 = hearing_aod_appeal.tasks.where(type: DistributionTask.name).first
dist_task1.assigned! unless dist_task1.assigned?
dist_task2.assigned! unless dist_task2.assigned?

Timecop.return
Timecop.travel(years_old.ago)

direct_review_cavc_appeal = create(
:appeal,
:dispatched,
:direct_review_docket,
associated_judge: judge,
associated_attorney: attorney,
veteran: create_veteran
)
evidence_submission_cavc_appeal = create(
:appeal,
:dispatched,
:evidence_submission_docket,
associated_judge: judge,
associated_attorney: attorney,
veteran: create_veteran
)

hearing_cavc_appeal = create(
:appeal,
:dispatched,
:hearing_docket,
associated_judge: judge,
associated_attorney: attorney,
veteran: create_veteran
)

Timecop.travel(1.year.from_now)

# remand_appeal will have no tasks completed on it
direct_review_cavc_remand = create(:cavc_remand, source_appeal: direct_review_cavc_appeal)
evidence_submission_cavc_remand = create(:cavc_remand, source_appeal: evidence_submission_cavc_appeal)
hearing_cavc_remand = create(:cavc_remand, source_appeal: hearing_cavc_appeal)

# return system time back to now, then go to desired date where appeal will be ready for distribution
Timecop.return

# complete the CAVC task and make the appeal ready to distribute
direct_review_cavc_remand.remand_appeal.tasks.where(type: SendCavcRemandProcessedLetterTask.name).first.completed!
evidence_submission_cavc_remand.remand_appeal.tasks.where(type: SendCavcRemandProcessedLetterTask.name).first.completed!
hearing_cavc_remand.remand_appeal.tasks.where(type: SendCavcRemandProcessedLetterTask.name).first.completed!
end
# rubocop:enable Metrics/AbcSize
end
end

0 comments on commit 6ca18ab

Please sign in to comment.