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

Route EvidenceOrArgumentMailTasks to the mail team upon creation #13671

Closed
4 tasks done
hschallhorn opened this issue Mar 11, 2020 · 4 comments
Closed
4 tasks done

Route EvidenceOrArgumentMailTasks to the mail team upon creation #13671

hschallhorn opened this issue Mar 11, 2020 · 4 comments
Assignees
Labels
Feature: generic-queue Priority: Medium Blocking issue w/workaround, or "second in" priority for new work. Product: caseflow-queue Stakeholder: BVA Functionality associated with the Board of Veterans' Appeals workflows/feature requests Team: Echo 🐬 Type: Bug

Comments

@hschallhorn
Copy link
Contributor

hschallhorn commented Mar 11, 2020

User story

As a mail team member, I need to be able to have actions for Evidence & Argument tasks, so that I can close them out

Acceptance criteria

  • EvidenceOrArgumentMailTasks are routed to the colocated team if the case has been dispatched
  • EvidenceOrArgumentMailTasks are routed to the MailTeam otherwise
  • EvidenceOrArgumentMailTasks are not routed to the hearing branch
  • Production tasks are cleaned up based on the routing logic

Release notes

Evidence & Argument tasks created before a case is assigned to a judge will now be routed to the mail team to close out. The hearing branch will no longer receive these tasks, even if there is a pending hearing. Production data has been updated to reflect this by reassigning any hearing branch EvidenceOrArgumentMailTasks to the mail team

Background/context

Automatic routing of mail tasks: #7906

Technical notes

Here is where we determine routing for these tasks.

Other notes

Resources/other links

@hschallhorn hschallhorn added Product: caseflow-queue Feature: generic-queue Stakeholder: BVA Functionality associated with the Board of Veterans' Appeals workflows/feature requests Team: Echo 🐬 Priority: Medium Blocking issue w/workaround, or "second in" priority for new work. labels Mar 11, 2020
@lomky
Copy link
Contributor

lomky commented Mar 13, 2020

what is this chart?

1 | 
2 | ||
3 | |||||||||
5 | ||
8 | 

Grandparent task (assigned to mail organization), parent task (assigned to default assignee organization), child task (is assigned to a user).

This mail task will have a different structure than every other mail task, as we don't want it to have a grandparent task (double org task).

Why 3?

  • Tests. Lots of tests. New tests. Probably not feature tests
  • Behavior update!
  • Check queue's in UI for various teams and members

Why 5?

  • A lot to do: backend, frontend, UI checks, tests.

@hschallhorn
Copy link
Contributor Author

hschallhorn commented Apr 30, 2020

Starting to think about how to fix prod tasks.

Should we just cancel all EoA tasks that are not assigned to the Mail team?
Reasoning: No appeal that would return case_active? as false should have an open EoA task.

mail_eoa_tasks = EvidenceOrArgumentMailTask.open.where(assigned_to: MailTeam.singleton)
closed_appeals = mail_eoa_tasks.map(&:appeal).select(&:active?)
closed_appeals.count
=> 14
# Look who was wrong! This is probably a case of #13438 

closed_appeals.last.treee
Appeal 25257 (hearing)                            ID     STATUS    ASGN_BY    ASGN_TO           UPDATED_AT
└── RootTask                                      379862 completed            Bva               2020-03-02 12:32:44 UTC
    ├── TrackVeteranTask                          379863 completed            FieldVso          2020-03-02 12:32:44 UTC
    ├── DistributionTask                          379864 completed            Bva               2020-01-29 21:08:55 UTC
       └── HearingTask                           379865 completed            Bva               2020-01-27 16:39:05 UTC
           ├── ScheduleHearingTask               379866 completed            Bva               2019-09-20 19:44:05 UTC
           └── AssignHearingDispositionTask      424323 completed            Bva               2020-01-27 16:39:04 UTC
               ├── TranscriptionTask             524298 completed            TranscriptionTeam 2020-01-27 16:39:04 UTC
               └── EvidenceSubmissionWindowTask  524299 completed            MailTeam          2020-01-14 17:34:49 UTC
    ├── EvidenceOrArgumentMailTask                638625 on_hold              MailTeam          2020-01-24 13:23:51 UTC
       └── EvidenceOrArgumentMailTask            638626 assigned  BVACANAGRO HearingAdmin      2020-01-24 13:23:51 UTC
    ├── EvidenceOrArgumentMailTask                638715 on_hold              MailTeam          2020-01-24 13:56:12 UTC
       └── EvidenceOrArgumentMailTask            638716 assigned  BVACANAGRO HearingAdmin      2020-01-24 13:56:12 UTC
    ├── JudgeAssignTask                           652601 completed            BVAAJAEGER        2020-02-03 15:07:49 UTC
    ├── JudgeDecisionReviewTask                   661393 completed            BVAAJAEGER        2020-02-27 20:35:05 UTC
       └── AttorneyTask                          661394 completed BVAAJAEGER BVANNORTHCUTT     2020-02-27 14:52:12 UTC
    └── BvaDispatchTask                           720494 completed            BvaDispatch       2020-03-02 12:32:44 UTC
        └── BvaDispatchTask                       720495 completed            VACOMILLEK2       2020-03-02 12:32:44 UTC
# Yup! Let's make sure none of these were created after the bva dispatch task

closed_appeals.map { |a| BvaDispatchTask.completed.find_by(appeal: a).created_at > EvidenceOrArgumentMailTask.open.find_by(appeal: a).created_at }.uniq
=> [true]
# Cool! I still have no issue cancelling the children tasks here. Let's see who these are assigned to

tasks_from_closed_appeals = mail_eoa_tasks.reject { |task| task.appeal.active? }
tasks_from_closed_appeals.map { |task| task.children.first.assigned_to.name }.uniq
=> ["Hearing Admin"]
# Great, now I feel EVEN BETTER about cancelling these.

# Let's look at the children of eoa tasks
mail_eoa_tasks.map(&:children).map(&:count).uniq
=> 1
Task.where(parent: mail_eoa_tasks).group(:assigned_to_id).count
=> {23=>1, 225=>259}
Organization.find(23).name
=> "VLJ Support Staff"
Organization.find(225).name
=> "Hearing Admin"
EvidenceOrArgumentMailTask.open.where(assigned_to_type: User.name).count
=> 1
EvidenceOrArgumentMailTask.open.where(assigned_to_type: User.name).first.appeal.treee
Appeal 55714 (evidence_submission)              ID     STATUS      ASGN_BY       ASGN_TO     UPDATED_AT
└── RootTask                                    659278 on_hold                   Bva         2020-01-31 19:55:27 UTC
    ├── TrackVeteranTask                        659279 in_progress               Vso         2020-01-31 19:55:27 UTC
    ├── DistributionTask                        659280 assigned                  Bva         2020-03-18 14:18:26 UTC
       └── EvidenceSubmissionWindowTask        659281 completed                 MailTeam    2020-03-18 14:18:25 UTC
    ├── EvidenceOrArgumentMailTask              694571 on_hold                   MailTeam    2020-02-18 15:20:08 UTC
       └── EvidenceOrArgumentMailTask          694572 on_hold     BVATDONALDSON Colocated   2020-02-18 15:20:08 UTC
           └── EvidenceOrArgumentMailTask      694573 on_hold     BVATDONALDSON BVALCLANTON 2020-02-20 17:42:37 UTC
               └── EvidenceOrArgumentMailTask  701804 assigned    BVALCLANTON   PrivacyTeam 2020-02-20 17:42:37 UTC
    └── EvidenceOrArgumentMailTask              763492 completed                 MailTeam    2020-03-18 14:33:29 UTC
        └── EvidenceOrArgumentMailTask          763493 completed   VACOMCWILJ    Colocated   2020-03-18 14:33:29 UTC
            ├── EvidenceOrArgumentMailTask      763494 cancelled   VACOMCWILJ    BVALCLANTON 2020-03-18 14:33:10 UTC
            └── EvidenceOrArgumentMailTask      763568 completed   VACOBOOKEK    VACOBOOKEK  2020-03-18 14:33:29 UTC
# Looks like we may want to leave this one be
# This also shows that no tasks assigned to the hearing admin team have child user tasks (no one has started work on these)

@hschallhorn
Copy link
Contributor Author

Let's think about what cancelling all of these (other than colocated) would look like!

mail_eoa_child_tasks = EvidenceOrArgumentMailTask.open.where(assigned_to: HearingAdmin.singleton)
mail_eoa_child_tasks.count
=> 259
# Purposely skip callbacks so we don't cancel the mail EoA task.
# This method also handles version saving and updating the closed at timestamp
mail_eoa_child_tasks.each(&:cancel_task_and_child_subtasks)

Will do some testing in dev in the morn.

va-bot pushed a commit that referenced this issue May 1, 2020
Connects #13671 

### Description
Updates the automated task routing for EvidenceOrArgumentMailTasks.

Does not address Unneeded Mail Org Task bug inherent in auto-routing mail tasks.

### Acceptance Criteria
- [x]  EvidenceOrArgumentMailTasks are routed to the colocated team if the case has been dispatched
- [x] EvidenceOrArgumentMailTasks are routed to the MailTeam otherwise
- [x] EvidenceOrArgumentMailTasks are never routed to the hearing branch 

### Testing Plan
#### Task tree testing
1. open your console and grab an active appeal
```ruby
appeal = Appeal.find { |a| a.active?  && a.tasks.where(type: EvidenceOrArgumentMailTask.name).empty? }
puts appeal.structure_render :status, :assigned_to_type, :assigned_to_id
```
``` ruby
> appeal = Appeal.find { |a| a.active?  && a.tasks.where(type: EvidenceOrArgumentMailTask.name).empty? }
> puts appeal.structure_render :status, :assigned_to_type, :assigned_to_id
Appeal 7 [status, assigned_to_type, assigned_to_id]
└── RootTask on_hold, Organization, 5
    └── TrackVeteranTask in_progress, Organization, 9
```
2. Create an `EvidenceOrArgumentMailTask` and confirm only one org task assigned to the mail team is created
```ruby
RequestStore[:current_user] = User.system_user
EvidenceOrArgumentMailTask.create_from_params({parent_id: appeal.root_task.id}, MailTeam.singleton.users.first)
puts appeal.structure_render :status, :assigned_to_type, :assigned_to_id
```
```ruby
> puts appeal.structure_render :status, :assigned_to_type, :assigned_to_id
Appeal 7 [status, assigned_to_type, assigned_to_id]
└── RootTask on_hold, Organization, 5
    ├── TrackVeteranTask in_progress, Organization, 9
    └── EvidenceOrArgumentMailTask assigned, Organization, 14
```
3. Close the root task to make the appeal inactive. Create another task and confirm it assigns Org Mail, Org Colocated, User Tasks.
```ruby
appeal.root_task.update(status: "completed")
appeal.active?
EvidenceOrArgumentMailTask.create_from_params({parent_id: appeal.root_task.id}, MailTeam.singleton.users.first)
puts appeal.structure_render :status, :assigned_to_type, :assigned_to_id
```

```
> puts appeal.structure_render :status, :assigned_to_type, :assigned_to_id
Appeal 7 [status, assigned_to_type, assigned_to_id]
└── RootTask completed, Organization, 5
    ├── TrackVeteranTask completed, Organization, 9
    ├── EvidenceOrArgumentMailTask assigned, Organization, 14
    └── EvidenceOrArgumentMailTask on_hold, Organization, 14
        └── EvidenceOrArgumentMailTask on_hold, Organization, 6
            └── EvidenceOrArgumentMailTask assigned, User, 17
Organization.find([14, 6]).map(&:name)
=> ["Mail", "VLJ Support Staff"]
```
#### UI testing
1. Log in as jolly postman and find an active appeal
```ruby
Appeal.find { |a| a.active?  && a.tasks.where(type: EvidenceOrArgumentMailTask.name).empty? }.uuid
=> "b21f2cc0-1e82-4571-a3ec-e41d2a064cae"
```
2. Visit this appeal page and create an evidence or argument task by clicking "+ Add a new task"
![Screen Shot 2020-04-30 at 2 25 35 PM](https://user-images.githubusercontent.com/45575454/80745736-c0388300-8aee-11ea-8bb3-ae6e2ffb0085.png)
![Screen Shot 2020-04-30 at 2 27 03 PM](https://user-images.githubusercontent.com/45575454/80745745-c2024680-8aee-11ea-9ab5-5a40cda1f2de.png)

3. Ensure the user can cancel, complete, or change the type of this task (may need to add a few more EoA tasks to get set back up into that state). Be sure to actually test these actions and they create expected task trees.
![Screen Shot 2020-04-30 at 2 27 13 PM](https://user-images.githubusercontent.com/45575454/80745798-d8a89d80-8aee-11ea-8b8d-732f5bc11d13.png)
@hschallhorn
Copy link
Contributor Author

@araposo-tistatech These should all be fixed. The 260 EvidenceOrArgumentMailTasks that were in the mail team's queue can now be acted on. If they would like to see the instructions there were originally created with, they can see the tasks we cancelled in the case timeline.
Screenshot_2020-05-11 Case Details Caseflow
Let me know if you have any questions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: generic-queue Priority: Medium Blocking issue w/workaround, or "second in" priority for new work. Product: caseflow-queue Stakeholder: BVA Functionality associated with the Board of Veterans' Appeals workflows/feature requests Team: Echo 🐬 Type: Bug
Projects
None yet
Development

No branches or pull requests

3 participants