Fixing task trees - department-of-veterans-affairs/caseflow GitHub Wiki

When the task tree cannot be restored to the correct state by actions available to Caseflow users (like cancelling a task), the Caseflow application development team can manually correct the state of the task tree. Examples of occasions when manual intervention was needed and the steps we took to correct the task tree are below.

ScheduleHearingTask accidentally cancelled and case was distributed to a judge

A member of the hearings branch reached out to support to report that they had accidentally cancelled a ScheduleHearingTask and wanted it returned to their queue so they could properly schedule a hearing for that case (link to the related Slack conversation). Because the case had already been distributed to a judge we could not simply re-open the previous ScheduleHearingTask. Instead we closed the existing JudgeAssignTask and followed the model laid out in InitialTasksFactory.create_subtasks! to create a new distribution task with the appropriate hearing tasks.

Full details below:

rails c> legacy_appeal = LegacyAppeal.find_by(vacols_id: 3075566)
rails c> veteran = legacy_appeal.veteran
rails c> appeal = Appeal.find_by(veteran_file_number: veteran.file_number)
rails c> puts appeal.structure_render(:id, :status, :created_at, :closed_at)
# Appeal 18410
  └── RootTask 330761, on_hold, 2019-08-14 17:36:04 UTC, (closed_at)
      ├── TrackVeteranTask 330763, in_progress, 2019-08-14 17:36:05 UTC, (closed_at)
      ├── DistributionTask 330764, completed, 2019-08-14 17:36:05 UTC, 2019-08-20 13:30:39 UTC
      │   └── HearingTask 330765, completed, 2019-08-14 17:36:05 UTC, 2019-08-19 21:30:15 UTC
      │       ├── ScheduleHearingTask 330766, cancelled, 2019-08-14 17:36:05 UTC, 2019-08-19 17:40:07 UTC
      │       └── EvidenceSubmissionWindowTask 338211, completed, 2019-08-19 17:40:07 UTC, 2019-08-19 21:30:15 UTC
      └── JudgeAssignTask 339679, assigned, 2019-08-20 13:30:39 UTC, (closed_at)
rails c> judge = JudgeAssignTask.find(339679).assigned_to
# Reach out to judge first before resetting the state of this appeal
rails c> distribution_task = DistributionTask.create!(appeal: appeal, parent: appeal.root_task)
rails c> ScheduleHearingTask.create!(appeal: appeal, parent: distribution_task)
rails c> JudgeAssignTask.find(339679).update!(status: Constants.TASK_STATUSES.cancelled)
# Are we in the correct state?
rails c> puts appeal.structure_render(:id, :status, :created_at, :closed_at)
# Appeal 18410
  └── RootTask 330761, on_hold, 2019-08-14 17:36:04 UTC, (closed_at)
      ├── TrackVeteranTask 330763, in_progress, 2019-08-14 17:36:05 UTC, (closed_at)
      ├── DistributionTask 330764, completed, 2019-08-14 17:36:05 UTC, 2019-08-20 13:30:39 UTC
      │   └── HearingTask 330765, completed, 2019-08-14 17:36:05 UTC, 2019-08-19 21:30:15 UTC
      │       ├── ScheduleHearingTask 330766, cancelled, 2019-08-14 17:36:05 UTC, 2019-08-19 17:40:07 UTC
      │       └── EvidenceSubmissionWindowTask 338211, completed, 2019-08-19 17:40:07 UTC, 2019-08-19 21:30:15 UTC
      ├── JudgeAssignTask 339679, cancelled, 2019-08-20 13:30:39 UTC, 2019-09-09 14:42:25 UTC
      └── DistributionTask 387249, on_hold, 2019-09-09 14:42:19 UTC, (closed_at)
          └── HearingTask 387251, on_hold, 2019-09-09 14:42:21 UTC, (closed_at)
              └── ScheduleHearingTask 387252, assigned, 2019-09-09 14:42:21 UTC, (closed_at)
# Looks good!