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

Defer the loading of user on_hold tasks #14142

Closed
4 tasks
lomky opened this issue Apr 30, 2020 · 26 comments
Closed
4 tasks

Defer the loading of user on_hold tasks #14142

lomky opened this issue Apr 30, 2020 · 26 comments
Assignees
Labels
Eng: Performance Priority: High Escalations from Support, blocking issue/NO workaround, or "first in" priority for new work. Product: caseflow-queue Source: Bat Team Source: User Feedback Stakeholder: BVA Functionality associated with the Board of Veterans' Appeals workflows/feature requests Team: Echo 🐬 Type: Tech-Improvement

Comments

@lomky
Copy link
Contributor

lomky commented Apr 30, 2020

Description

Right now when a User navigates to their /queue, we grab all the open tasks assigned to the user plus all of their recently completed tasks. As time has gone on and users are doing more and more work in Caseflow, User on_hold numebrs are going up to a point that they are experiencing load times of nearly a minute, even though they only have a handful of tasks to immediately work.

This issue is to prioritize loading of active issues first and foremost, and defer to loading of on_hold and recently completedtasks until the user actively requests those tasks by clicking on their associated tab.

Acceptance criteria

  • User queues load only the tasks needed for the default tab (Assigned/Assign/Review) when a user first loads /queue
  • User on_hold tab still shows the correct number of on_hold tasks
  • on_hold tasks are queried and displayed when the user selects that tab
  • recently completed tasks are queried and displayed when the user selects that tab

Background/context/resources

Discussion thread

Technical notes

It's important to handle tasks that were active but have since become on hold in a users queue, such as if they have assigned a case over to another team, and return those tasks so they are unloaded from the users active tab.
See the implementation of a similar need for Judge queues, though that ticket does not cover the second AC of loading on_hold on request.

@lomky lomky added Type: Tech-Improvement Source: User Feedback Product: caseflow-queue Eng: Performance Stakeholder: BVA Functionality associated with the Board of Veterans' Appeals workflows/feature requests Source: Bat Team Team: Echo 🐬 Priority: Medium Blocking issue w/workaround, or "second in" priority for new work. labels Apr 30, 2020
@lomky lomky changed the title Defer the loading of user on_hold tasks Defer the loading of user on_hold tasks Apr 30, 2020
@lomky lomky added Priority: High Escalations from Support, blocking issue/NO workaround, or "first in" priority for new work. and removed Priority: Medium Blocking issue w/workaround, or "second in" priority for new work. labels Apr 30, 2020
@ajspotts
Copy link
Contributor

what is this chart?

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

Reminder: record load times before and after the improvement. (may be available in the DevTools Network console tab)

Why 3?

  • Can borrow some "should load tasks" logic from pagination in org queues

Why 5?

  • Imagine all the wrangling of tasks in state to determine if we should load tasks, front end requests, controller updates to allow tab or status to be specified, same for queue for role and the respective queues.
  • Grabbing task counts for each tab may not already be done in queue config
  • backend and front end changes, affects all three User queue types

@hschallhorn
Copy link
Contributor

First option was to add pagination to user queues. Allows us to reuse a bunch of code we already have implemented. However. We cannot paginate judge and attorney queues as their queues also show legacy tasks, which are not persisted in our database and cannot be sorted/filtered. Judge queues are already mildly handled as we do not return on hold tasks to the front end. Let's see if any attorney queues are an issue.

Task.open.where(assigned_to_type: User.name).group(:assigned_to_id).order(:count).count
... 1605=>100, 2143=>106, 11350=>107, 1608=>121, 1607=>124, 3772=>170, 2062=>209, 10630=>211, 3482=>220, 14143=>226, 10627=>251, 2101=>259, 1379=>278, 1782=>285, 7798=>296, 1967=>302, 2141=>317, 2012=>341, 1829=>372, 6169=>424, 2014=>436, 546=>462, 1885=>483, 2227=>486}
power_user_ids = Task.open.where(assigned_to_type: User.name).group(:assigned_to_id).order(:count).count.keys.last(25)
power_user_ids.select { |id| User.find(id).attorney_in_vacols? && !User.find(id).judge_in_vacols? }
=> [2101]
# Looks like we only have one atty with over 100 tasks

power_atty = User.find(2101)
tasks = QueueForRole.new("attorney").create(user: power_atty).tasks
tasks.count
=> 293
Benchmark.measure { AmaAndLegacyTaskSerializer.create_and_preload_legacy_appeals(params: { user: power_atty, role: "attorney" }, tasks: tasks, ama_serializer: WorkQueue::TaskSerializer).call }
=> #<Benchmark::Tms:0x000000000b4436c0 @label="", @real=48.63590942599967, @cstime=0.0, @cutime=0.0, @stime=0.45306500000000005, @utime=11.936532, @total=12.389597>

@hschallhorn hschallhorn self-assigned this May 12, 2020
va-bot pushed a commit that referenced this issue May 15, 2020
# THIS PR
Part 1 of stack to speed up user queues and bump #14142
[Part 2](#14253)

## Description
Creates an endpoint to request the paged tasks of a user

## AC
- [x] Tests pass (no visible changes)

## Testing
```ruby
# Log in as a colocated user
user = User.find_by_css_id("BVALSPORER")
FeatureToggle.enable!(:user_queue_pagination, users: [user.css_id])
User.authentication_service = Fakes::AuthenticationService
User.authentication_service.user_session = User.authentication_service.get_user_session(user.id)

# Create some tasks for them
3.times do 
  ColocatedTask.actions_assigned_to_colocated.map(&:to_sym).each do |action|
    appeal = FactoryBot.create(:appeal)
    parent = FactoryBot.create(
      :ama_task,
      assigned_to: User.first,
      assigned_by: User.first,
      appeal: appeal
    )
    task = FactoryBot.create(
      :ama_colocated_task,
      action,
      assigned_to: Colocated.singleton,
      appeal: appeal,
      assigned_by: User.first,
      parent_id: parent.id
    )
    task.children.first.on_hold!
  end
end

# Get set up to make some requests!
app.get '/'
csrf=app.session.to_hash["_csrf_token"]
base_url = "/users/#{user.id}/task_pages?authenticity_token=#{CGI.escape csrf}&"

# Base request for assigned tasks
params = "tab=assigned_person"
app.get "#{base_url}#{params}"
response_body = JSON.parse(app.response.body); nil
response_body["tasks"]["data"].count
=> 15 # May be different for you but should be no higher than 15
response_body["total_task_count"].eql? Task.active.where(assigned_to: user).count
=> true

# on hold tasks
params = "tab=on_hold_person"
app.get "#{base_url}#{params}"
response_body = JSON.parse(app.response.body); nil
response_body["tasks"]["data"].count
=> 15
response_body["total_task_count"].eql? Task.on_hold.where(assigned_to: user).count
=> true

# sorted tasks
params = "tab=on_hold_person&sort_by=taskColumn"
app.get "#{base_url}#{params}"
response_body = JSON.parse(app.response.body); nil
tasks = response_body["tasks"]["data"]; nil
tasks.map { |task| task["attributes"]["type"] }
=> ["AddressVerificationColocatedTask",
 "AddressVerificationColocatedTask",
 "AddressVerificationColocatedTask",
 "AddressVerificationColocatedTask",
 "AddressVerificationColocatedTask",
 "ExtensionColocatedTask",
 "ExtensionColocatedTask",
 "ExtensionColocatedTask",
 "ExtensionColocatedTask",
 "ExtensionColocatedTask",
 "HearingClarificationColocatedTask",
 "HearingClarificationColocatedTask",
 "HearingClarificationColocatedTask",
 "HearingClarificationColocatedTask",
 "HearingClarificationColocatedTask"]


# paged sorted tasks
params = "tab=on_hold_person&sort_by=taskColumn&page=2"
app.get "#{base_url}#{params}"
response_body = JSON.parse(app.response.body); nil
tasks = response_body["tasks"]["data"]; nil
tasks.map { |task| task["attributes"]["type"] }
=> ["IhpColocatedTask",
 "IhpColocatedTask",
 "IhpColocatedTask",
 "IhpColocatedTask",
 "IhpColocatedTask",
 "NewRepArgumentsColocatedTask",
 "NewRepArgumentsColocatedTask",
 "NewRepArgumentsColocatedTask",
 "NewRepArgumentsColocatedTask",
 "NewRepArgumentsColocatedTask",
 "RetiredVljColocatedTask",
 "RetiredVljColocatedTask",
 "RetiredVljColocatedTask",
 "RetiredVljColocatedTask",
 "RetiredVljColocatedTask"]

# Filtered tasks
params = "tab=on_hold_person&filter%5B%5D=col%3DtaskColumn%26val%3DIhpColocatedTask"
app.get "#{base_url}#{params}"
response_body = JSON.parse(app.response.body); nil
tasks = response_body["tasks"]["data"]; nil
tasks.map { |task| task["attributes"]["type"] }.uniq
=> ["IhpColocatedTask"]
```

# THE FULL STACK
<details>
  <summary>spoilers!</summary>
Part 2 of stack to bump #14142
[Part 1](#14252)

## Description
Allows user queues to be paginated

## Testing
1. Log in as BVALSPORER
1. Pad your queue with some tasks
```ruby
3.times do 
  ColocatedTask.actions_assigned_to_colocated.map(&:to_sym).each do |action|
    appeal = FactoryBot.create(:appeal)
    parent = FactoryBot.create(
      :ama_task,
      assigned_to: User.first,
      assigned_by: User.first,
      appeal: appeal
    )
    task = FactoryBot.create(
      :ama_colocated_task,
      action,
      assigned_to: Colocated.singleton,
      appeal: appeal,
      assigned_by: User.first,
      parent_id: parent.id
    )
    task.children.first.on_hold!
  end
end
```
3. Enable pagination
```ruby
FeatureToggle.enable!(:user_queue_pagination, users: ["BVALSPORER"])
```
4. Test Pagination!

### Initial queue load only loads first page of tasks
With dev tools open, got to the user's queue
![Screen Shot 2020-05-12 at 3 58 34 PM](https://user-images.githubusercontent.com/45575454/81739509-7d20cd00-9469-11ea-8829-ec8cdb4ee8de.png)
- [ ] This request for tasks only returns the first 15 tasks for each tab.
- [ ] `total_task_count` and `task_page_count` are correct 
- [ ] This request does not return all tasks assigned to the user in `tasks: { data: [] }`

### Filtering, sorting, paging, and switching tabs work
Try a combination of filtering and sorting to confirm the correct tasks are show. Bonus points for trying the same combination more than once and noticing the loading page is not shown because we're pulling from cached results. Each request should only return 15 tasks.
![Screen Shot 2020-05-12 at 4 44 16 PM](https://user-images.githubusercontent.com/45575454/81744429-36cf6c00-9471-11ea-86fe-228910c81f7c.png)

#### Sorting
![Screen Shot 2020-05-12 at 4 06 09 PM](https://user-images.githubusercontent.com/45575454/81740197-90806800-946a-11ea-9f44-8cb220782308.png)
![Screen Shot 2020-05-12 at 4 06 22 PM](https://user-images.githubusercontent.com/45575454/81740201-92e2c200-946a-11ea-9892-cc749ce49e3f.png)
- [ ] Sorting on a column
   - [ ] Displays the tasks in the correct order
   - [ ] Affects tasks on higher number pages
   - [ ] Updates the address bar to show sorting (confirm this url is correct by bookmarking this page and clicking the bookmark. It should show the same order of tasks and the correct indicator of which column is being sorted http://localhost:3000/queue?tab=assigned_person&page=2&sort_by=taskColumn&order=desc)

#### Filtering
![Screen Shot 2020-05-12 at 4 14 55 PM](https://user-images.githubusercontent.com/45575454/81740949-c540ef00-946b-11ea-9d8a-402742983e91.png)
![Screen Shot 2020-05-12 at 4 15 06 PM](https://user-images.githubusercontent.com/45575454/81740961-c7a34900-946b-11ea-901b-f02e588ac87b.png)

- [ ] Filtering on a column
   - [ ] Displays the correctly filtered tasks
   - [ ] Affects tasks on higher number pages
   - [ ] Updates the address bar to show filtering (confirm this url is correct by bookmarking this page and clicking the bookmark. It should show the same filtered tasks and the correct indicator of which column is being filtered http://localhost:3000/queue?tab=on_hold_person&page=2&filter%5B%5D=col%3DtaskColumn%26val%3DAddressVerificationColocatedTask%7CExtensionColocatedTask%7CHearingClarificationColocatedTask%7CIhpColocatedTask)

### Paging
![Screen Shot 2020-05-12 at 4 12 27 PM](https://user-images.githubusercontent.com/45575454/81740826-932f8d00-946b-11ea-8e90-59195b1ca167.png)
![Screen Shot 2020-05-12 at 4 12 35 PM](https://user-images.githubusercontent.com/45575454/81740832-96c31400-946b-11ea-9143-d85551c630a3.png)
- [ ] Going to a new page
    - [ ] Preserves any filtering
    - [ ] Preserves any sorting
    - [ ] Displays the correct "showing tasks x of xx"
    - [ ] Updates the address bar to show paging (confirm this url is correct by bookmarking this page and clicking the bookmark. It should show the same page of tasks and the correct page indicator http://localhost:3000/queue?tab=on_hold_person&page=2)

### Changing tabs
![Screen Shot 2020-05-12 at 4 18 40 PM](https://user-images.githubusercontent.com/45575454/81741269-4b5d3580-946c-11ea-9fde-426b3cd115f7.png)
![Screen Shot 2020-05-12 at 4 18 53 PM](https://user-images.githubusercontent.com/45575454/81741274-4c8e6280-946c-11ea-8bbd-00a47d84726b.png)
- [ ] Changing tabs
   - [ ] Changes the tab (I ddon't know what you expected here
   - [ ] Updates the address bar to show the updated tab (confirm this url is correct by bookmarking this page and clicking the bookmark. It should show the same tab of tasks and the correct tab indicator http://localhost:3000/queue?tab=on_hold_person&page=1)

### Any combinations of the above
- [ ] Go ahead, get crazy
- [ ] Incorrect combinations should update the page and address bar to the default (page 1, assigned tab, no sort, sort asc, no filter, correct filters) (Confirm the invalid URL is replaced with a valid one)
    - [ ] [`?tab=INVALID_TAB_NAME`](http://localhost:3000/queue?tab=INVALID_TAB_NAME)
 `?tab=unassigned_person&page=1`
    - [ ] [`?tab=assigned_person&page=20`](http://localhost:3000/queue?tab=assigned_person&page=1) 
  `?tab=assigned_person&page=1`
    - [ ] [`?tab=assigned_person&page=-12`](http://localhost:3000/queue?tab=assigned_person&page=-12) 
  `?tab=assigned_person&page=1`
    - [ ] [`?tab=assigned_person&page=1&sort_by=INVALID_COLUMN`](http://localhost:3000/queue?tab=assigned_person&page=1&sort_by=INVALID_COLUMN) 
  `?tab=assigned_person&page=1`
    - [ ] [`?tab=assigned_person&page=1&sort_by=taskColumn&order=INVALID_SORT_ORDER`](http://localhost:3000/queue?tab=assigned_person&page=1&sort_by=taskColumn&order=INVALID_SORT_ORDER) 
  `?tab=assigned_person&page=1&sort_by=taskColumn&order=asc` (Notice the sort order is defaulted to asc)
    - [ ] [`?tab=assigned_person&page=1&filter%5B%5D=col%3DINVALID_COLUMN_NAME%26val%3DAojColocatedTask`](http://localhost:3000/queue?tab=assigned_person&page=1&filter%5B%5D=col%3DINVALID_COLUMN_NAME%26val%3DAojColocatedTask) 
  `?tab=assigned_person&page=1`
    - [ ] [`?tab=assigned_person&page=1&filter%5B%5D=col%3DtaskColumn%26val%3DINVALID_FILTER_VALUE`](http://localhost:3000/queue?tab=assigned_person&page=1&filter%5B%5D=col%3DtaskColumn%26val%3DINVALID_FILTER_VALUE) 
  `?tab=assigned_person&page=1`
    - [ ] [`?tab=assigned_person&page=1&filter%5B%5D=col%3DtaskColumn%26val%3DAojColocatedTask%7CINVALID_FILTER_VALUE`](http://localhost:3000/queue?tab=assigned_person&page=1&filter%5B%5D=col%3DtaskColumn%26val%3DAojColocatedTask%7CINVALID_FILTER_VALUE) 
  `?tab=assigned_person&page=1&filter%5B%5D=col%3DtaskColumn%26val%3DAojColocatedTask` (Notice correct filter is preserved)


## THINGS THAT SHOULD NOT HAVE CHANGED
 - [ ] The appearance and functionality of attorney queues

BEFORE|AFTER
---|---
![Screen Shot 2020-05-12 at 4 36 33 PM](https://user-images.githubusercontent.com/45575454/81742936-d808f300-946e-11ea-9f28-0e141f80d41f.png)|![Screen Shot 2020-05-12 at 4 37 32 PM](https://user-images.githubusercontent.com/45575454/81742977-ed7e1d00-946e-11ea-9511-8286d1ff5b9f.png)
![Screen Shot 2020-05-12 at 4 36 52 PM](https://user-images.githubusercontent.com/45575454/81742946-dc351080-946e-11ea-8fe7-db6d58ab69bf.png)|![Screen Shot 2020-05-12 at 4 37 39 PM](https://user-images.githubusercontent.com/45575454/81743001-f40c9480-946e-11ea-9b5d-4e8b744a2a0e.png)


 - [ ] The appearance and functionality of judge queues

BEFORE|AFTER
---|---
![Screen Shot 2020-05-12 at 4 35 04 PM](https://user-images.githubusercontent.com/45575454/81742799-a728be00-946e-11ea-9ac0-b7c89cdec383.png)|![Screen Shot 2020-05-12 at 4 35 34 PM](https://user-images.githubusercontent.com/45575454/81742812-ac860880-946e-11ea-96bf-3e1d9134b070.png)

 - [ ] The appearance and functionality of organization queues

BEFORE|AFTER
---|---
![Screen Shot 2020-05-12 at 4 33 28 PM](https://user-images.githubusercontent.com/45575454/81742614-60d35f00-946e-11ea-95cf-e95dd8db73ac.png) | ![Screen Shot 2020-05-12 at 4 33 44 PM](https://user-images.githubusercontent.com/45575454/81742626-64ff7c80-946e-11ea-9463-158789f852e7.png)


</details>
@hschallhorn
Copy link
Contributor

@araposo-tistatech The pagination of user (non attorney and judges) queues is merged and will be released after the weekend. This is behind a feature flag. Do we want to identify some users to test this out with before we enable it for all? Perhaps with the user from this thread would be a good start.

@araposo-tistatech
Copy link

@hschallhorn absolutely, I can't immediately identify the user in the thread (slack is not taking me directly to the thread for some reason), but I will request users from a few organizations we can test with.

@araposo-tistatech
Copy link

Confirming user request was sent.

@araposo-tistatech
Copy link

@hschallhorn below are the names of users I've received:

Michael Theriot
Chandra Tyler
Kristian Berhost
Robert Carter
Naheem Grant
Lazette Clanton
Ronald Bergeron
Andrew Kim
Shaliah Benton

@hschallhorn
Copy link
Contributor

hschallhorn commented May 21, 2020

user_names = ["Michael Theriot", "Chandra Tyler", "Kristian Berhost", "Robert Carter", "Naheem Grant", "Lazette Clanton", "Ronald Bergeron", "Andrew Kim", "Shaliah Benton"]
users = User.where(full_name: user_names.map(&:upcase))
counts = Task.open.where(assigned_to: users).group(:assigned_to_id).order(:count).count
=> {11140=>29, 14385=>106, 14143=>241, 3482=>299, 6169=>415, 2014=>437}
counts.map { |k, v| User.find(k).full_name }
=> ["NAHEEM GRANT", "KRISTIAN BERHOST", "ANDREW KIM", "SHALIAH BENTON", "ROBERT CARTER", "RONALD BERGERON", "LAZETTE CLANTON"]

@araposo-tistatech Looks like our best bets are (in order of the most tasks)

  1. LAZETTE CLANTON
  2. RONALD BERGERON
  3. ROBERT CARTER
  4. SHALIAH BENTON
  5. ANDREW KIM
  6. KRISTIAN BERHOST
  7. NAHEEM GRANT

Side note, these users have no tasks assigned to them

  1. CHANDRA TYLER
  2. MICHAEL THERIOT
  3. NAHEEM GRANT
puts users.select { |user| Task.open.where(assigned_to: user).blank? }.map(&:full_name)

@araposo-tistatech
Copy link

Hi @hschallhorn Lazette Clanton is all set to have the feature enabled on Tuesday. Let's work together to schedule a time to turn it on.

@araposo-tistatech
Copy link

Hi @hschallhorn Lazette is out of the office today, but Ronald is available, let's setup the testing for him instead.

@araposo-tistatech
Copy link

@hschallhorn 1pm please.

@hschallhorn
Copy link
Contributor

@araposo-tistatech department-of-veterans-affairs/appeals-deployment#2762 Will enable this for Lazette when we hear back on when she'd like to try it out!

@hschallhorn
Copy link
Contributor

Thinking out loud.
Attorneys and judges cannot use pagination because legacy tasks are not persisted in our database (which means they cannot be sorted and filtered at the database level on the back end). HOWEVER, legacy tasks will never appear in a users on hold or completed tab as we can only pull legacy appeals from vacols that are currently assigned to the user. Could we implement pagination for those two tabs only?

@hschallhorn
Copy link
Contributor

Looking for attorneys to test!

attorney_ids = AttorneyTask.pluck(:assigned_to_id).uniq
attorneys = User.where(id: attorney_ids)
assigned_to_counts = Task.incomplete_or_recently_completed.where(assigned_to: attorneys).group(:assigned_to_id).order(:count).count
assigned_by_counts = ColocatedTask.open.where(assigned_by: attorneys).group(:assigned_by_id).order(:count).count
total_counts = assigned_to_counts.merge(assigned_by_counts) { |id, assigned_to_count, assigned_by_count| assigned_to_count + assigned_by_count }.sort_by { |id, count| count }.to_h

pp total_counts.last(10).map { |id, count| ["#{User.find(id).css_id}: #{User.find(id).full_name}", count] }.to_h
{"VACOCHOC: CYNTHIA CHO"=>53,
 "VACOTEMPLB: BLAKE TEMPLE"=>54,
 "VACOMORRAS: SHABNAM MORRAD"=>58,
 "VACOSCHICS: SUZANNE SCHICK"=>59,
 "VACOZHENGA3: ANDREW ZHENG"=>62,
 "BVARWATKINS: ROBERT WATKINS"=>65,
 "VACOALHINM: MOHAMMAD ALHINNAWI"=>66,
 "VACOTROTTR: RENEE TROTTER"=>71,
 "BVASBOEHM: SHAUNA WATKINS"=>80,
 "VACOKOMINB: BENTON KOMINS"=>102}

@araposo-tistatech
Copy link

@hschallhorn below are the attorneys we are approved to test with and schedule for enabling the feature:
Robert Watkins - 6/03 at 10 am EST
Blake Temple - 6/04 at 10 am EST
Benton Komins - 6/04 at 10 am EST

@hschallhorn
Copy link
Contributor

hschallhorn commented Jun 2, 2020

We'll probably need at least until next week before this work for attorneys in done. Still working on priority stuff for this sprint before I can get back to this ticket!

@hschallhorn
Copy link
Contributor

hschallhorn commented Jul 8, 2020

@araposo-tistatech Updated list if we want to pull the heaviest users now that we're ready to test!

attorney_ids = AttorneyTask.pluck(:assigned_to_id).uniq
attorneys = User.where(id: attorney_ids)
assigned_to_counts = Task.on_hold.or(Task.recently_completed).where(assigned_to: attorneys).group(:assigned_to_id).order(:count).count
assigned_by_counts = ColocatedTask.open.where(assigned_by: attorneys).group(:assigned_by_id).order(:count).count
total_counts = assigned_to_counts.merge(assigned_by_counts) { |id, assigned_to_count, assigned_by_count| assigned_to_count + assigned_by_count }.sort_by { |id, count| count }.to_h

pp total_counts.map { |id, count| ["#{User.find(id).css_id}: #{User.find(id).full_name}", count] }.last(10).to_h
{"BVASSHOREMAN: SCOTT SHOREMAN"=>45,
 "VACOSMITHA2: AARON SMITH"=>47,
 "BVATDOUGLAS: THOMAS DOUGLAS"=>48,
 "VACOKETTLR: RICHARD KETTLER"=>48,
 "VACOZHENGA3: ANDREW ZHENG"=>49,
 "BVAMTHOMAS: MEGAN THOMAS"=>54,
 "BVASBOEHM: SHAUNA WATKINS"=>60,
 "VACOSCHICS: SUZANNE SCHICK"=>64,
 "VACOKOMINB: BENTON KOMINS"=>80,
 "BVABBARON: BRITTANY BARON"=>99}

@araposo-tistatech
Copy link

araposo-tistatech commented Jul 21, 2020

Please enable this feature for tomorrow at 10am for the following users:

Andrew Zheng - VACOZHENGA3
Shabnam Morrad - VACOMORRAS
Blake Temple - VACOTEMPLB
Benton Komins - VACOKOMINB
Robert Watkins - BVARWATKINS

@araposo-tistatech
Copy link

Initial pilot feedback:
Robert Watkins - "I don't really see the difference in my account. Generally it is well organized and easy to navigate."
I inquired further with this user to see if he can see a difference in load times and he stated he does not. "It seems about the same to me."

@araposo-tistatech
Copy link

@hschallhorn (pinging you since I know you are keeping a close watch on this one), Andrew Zheng has provided great feedback, but has also flagged a bug that I am unsure existed before enabling this. He stated that on the "On Hold" tab the issues column is displaying all cases have only one issue in them even though he knows there are more issues in the cases. So far he is the only user reporting this.

@hschallhorn
Copy link
Contributor

attorneys = User.where(css_id: ["VACOZHENGA3", "VACOMORRAS", "VACOTEMPLB", "VACOKOMINB", "BVARWATKINS"])
assigned_to_counts = Task.on_hold.or(Task.recently_completed).where(assigned_to: attorneys).group(:assigned_to_id).order(:count).count
assigned_by_counts = ColocatedTask.open.where(assigned_by: attorneys).group(:assigned_by_id).order(:count).count
total_counts = assigned_to_counts.merge(assigned_by_counts) { |id, assigned_to_count, assigned_by_count| assigned_to_count + assigned_by_count }.sort_by { |id, count| count }.to_h
total_counts.map { |judge_id, count| [User.find(judge_id).css_id, count] }.to_h
=> {"VACOTEMPLB"=>29, "BVARWATKINS"=>41, "VACOMORRAS"=>42, "VACOZHENGA3"=>51, "VACOKOMINB"=>78}

Most interested in Benton's feedback

@hschallhorn
Copy link
Contributor

hschallhorn commented Jul 22, 2020

user = User.find_by(css_id: "VACOZHENGA3")
queue_config = QueueConfig.new(assignee: user).to_hash
tasks = queue_config[:tabs][1][:tasks]
tasks.map { |task| task[:attributes][:issue_count] }.uniq
=> [1]

Looking into this now!

looks like this is happening for all legacy cases, reproduced in dev as well

task_ids = tasks.select {|task| task[:attributes][:docket_name] == "legacy" }.map{ |task| task[:id] }
appeals = Task.where(id: task_ids).map(&:appeal)
appeals.map { |appeal| appeal.issues.count }
=> [2, 3, 4, 3, 1, 3, 1, 6, 2, 2, 2, 2, 1, 5]
tasks.select {|task| task[:attributes][:docket_name] == "legacy" }.map { |task| task[:attributes][:issue_count] }
=> [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
CachedAppeal.where(appeal_type: LegacyAppeal.name, appeal_id: appeals.pluck(:id)).pluck(:issue_count)
=> [2, 1, 3, 3, 5, 1, 4, 3, 2, 2, 2, 6, 2, 1]

How are we determining issue count in queue config?

attribute :issue_count do |object, params|
columns = [Constants.QUEUE_CONFIG.COLUMNS.ISSUE_COUNT.name]
if serialize_attribute?(params, columns)
object.appeal.number_of_issues
end
end

appeals.map { |appeal| appeal.number_of_issues }
=> [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
appeals.map { |appeal| appeal.case_record.case_issues.length }
=> [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]

How were we determining issue counts for legacy appeals?

attribute :issue_count do |object|
object.appeal.undecided_issues.count
end

appeals.map { |appeal| appeal.undecided_issues.count }
=> [2, 3, 4, 2, 1, 3, 1, 6, 2, 2, 2, 2, 1, 2]

va-bot pushed a commit that referenced this issue Jul 22, 2020
Resolves bug detailed [here](#14142 (comment))

### Description
Fixes bug based on investigation [here](#14142 (comment))

### Acceptance Criteria
- [x] Number of issues  for legacy appeals is correct in queue
   - [x] on initial load
   - [x] after filtering

### Testing Plan
1. Log in a steve casper
1. Ensure user pagination is on
   ```ruby
   FeatureToggle.enabled?(:user_queue_pagination, user: User.first)
   => true
   ```
1. Go to http://localhost:3000/queue?tab=on_hold_person and confirm legacy case issue counts are not all "1"
1. Filter by legacy docket and confirm the same as well

### User Facing Changes
 - [ ] issue counts in queue are correct for legacy appeals rather than just "1"

 BEFORE|AFTER
 ---|---
![Screen Shot 2020-07-22 at 3 14 39 PM](https://user-images.githubusercontent.com/45575454/88220058-7a441480-cc30-11ea-874b-a39d67c7dee1.png)|![Screen Shot 2020-07-22 at 3 27 21 PM](https://user-images.githubusercontent.com/45575454/88220065-7d3f0500-cc30-11ea-8ea7-95666d3f62a4.png)
![Screen Shot 2020-07-22 at 3 32 33 PM](https://user-images.githubusercontent.com/45575454/88220130-95af1f80-cc30-11ea-9d6d-1075d80c91fa.png)|![Screen Shot 2020-07-22 at 3 25 02 PM](https://user-images.githubusercontent.com/45575454/88220133-98117980-cc30-11ea-904e-17f4bc744295.png)
@araposo-tistatech
Copy link

@hschallhorn more feedback provided:

B. Temple:

  1. The loading time navigating to the queue was fine. I did not notice any time lag compared to normal loading.
  2. The sorting and filtering of the on-hold cases worked without any problem.

Any further feedback we need here? It seems as though there is not much impact for attorneys.

@hschallhorn
Copy link
Contributor

No news is good enough news for me! happy to release whenever!

@araposo-tistatech
Copy link

@hschallhorn confirmed with the Board we are all set to release for tomorrow.

@hschallhorn
Copy link
Contributor

Released weeks ago, no reported issues thus far

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Eng: Performance Priority: High Escalations from Support, blocking issue/NO workaround, or "first in" priority for new work. Product: caseflow-queue Source: Bat Team Source: User Feedback Stakeholder: BVA Functionality associated with the Board of Veterans' Appeals workflows/feature requests Team: Echo 🐬 Type: Tech-Improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants