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

Avoid VACOLS calls on already scheduled veterans page - Part 1 #13668

Merged
merged 18 commits into from
Mar 12, 2020

Conversation

ferristseng
Copy link
Contributor

Description

Fixes some performance issues on the already scheduled veterans page that were reported to batteam

  • Create special serializer that returns only the necessary attributes for the already scheduled veterans table
  • Fix issue where hearing time on already scheduled veterans table wasn't accurate
    • Refactor daily docket and already scheduled veterans table to use shared HearingTime component
  • Refactor time-related hearing code to concern
  • Fix some prop type warnings
  • Ensure an attribuet called aod is always passed to the frontend

@@ -4,10 +4,9 @@ class HearingSerializer
include FastJsonapi::ObjectSerializer
include HearingSerializerBase

attribute :aod, &:aod?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The frontend expects a field named aod, but it wasn't being returned before for AMA hearings

};

export const getTimeInDifferentTimeZone = (date, timeZone) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing getTime and getTimeInDifferentTimeZone since they aren't used. I also think the server is responsible for doing a lot of the time conversions

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the server converting the time to the timezone of the hearing location? What if that differs from the timezone in which the user is currently viewing Caseflow? That could lead to incorrect time displays depending on if the user is in a different TZ than the hearing, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the server converting the time to the timezone of the hearing location?

Yep, the time the server sends down is in the timezone of the regional office (although it sends the time as a string).

What if that differs from the timezone in which the user is currently viewing Caseflow? That could lead to incorrect time displays depending on if the user is in a different TZ than the hearing, right?

It always show the time in the timezone of the RO. I think this makes sense, since the people viewing this page should either be in the RO of the hearing or in the CO (users are judge, representative, or hearing coordinator). This is getting blurrier though now because hearings can be conducted across state lines.

@ferristseng ferristseng changed the title Avoid VACOLS calls on already scheduled veterans page Avoid VACOLS calls on already scheduled veterans page - Part 1 Mar 11, 2020
@codeclimate
Copy link

codeclimate bot commented Mar 11, 2020

Code Climate has analyzed commit be866fd and detected 0 issues on this pull request.

View more on Code Climate.

Copy link
Contributor

@jcq jcq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is great — huge performance increases that should come of this, and I love that it lets us remove the artificial limit on entries returned (this likely will open up lots more possibilities for UI improvements, like fast in-browser pagination, etc).

What is the best way to test it? I was looking at it locally, but I'm not sure which regional offices are supposed to have decent amounts of seed data. Are there specs that might populate in tons of data to be able to gauge performance?

);
const coTime = getDisplayTime(hearing.centralOfficeTimeString, 'America/New_York');

if (hearing.readableRequestType === 'Central') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only see a couple of differences between what's being rendered in this block and the main one... might be better to just have one return and simply add conditionals for the couple of places where they diverge?

import DocketTypeBadge from '../../../components/DocketTypeBadge';

export const HearingTime = ({ hearing, isCentralOffice }) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huzzah to splitting this out into its own file!

@@ -87,7 +66,7 @@ export const HearingDocketTag = ({ hearing }) => {
HearingDocketTag.propTypes = {
hearing: PropTypes.shape({
docketName: PropTypes.string,
docketNumber: PropTypes.string
docketNumber: PropTypes.number
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love fixing up PropTypes. :)

};

export const getTimeInDifferentTimeZone = (date, timeZone) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the server converting the time to the timezone of the hearing location? What if that differs from the timezone in which the user is currently viewing Caseflow? That could lead to incorrect time displays depending on if the user is in a different TZ than the hearing, right?

@ferristseng
Copy link
Contributor Author

ferristseng commented Mar 12, 2020

What is the best way to test it? I was looking at it locally, but I'm not sure which regional offices are supposed to have decent amounts of seed data. Are there specs that might populate in tons of data to be able to gauge performance?

Unfortunately, there isn't a great way to test the performance of this locally without modifying the seeds.rb file. That was a big part of why I tested performance directly in production, and just tested for basic functionality locally.

These RO's should have data (but probably enough to be able to gauge performance):

Central
St. Petersburg, FL
Columbia, SC
St. Louis, MO
Oakland, CA
Phoenix, AZ

If you do want to go with the route of modifying seeds.rb, you could potentially modify this method

caseflow/db/seeds.rb

Lines 288 to 317 in dcb3886

def create_hearing_days
user = User.find_by(css_id: "BVATWARNER")
# Set the current user var here, which is used to populate the
# created by field.
RequestStore[:current_user] = user
%w[C RO17 RO19 RO31 RO43 RO45].each do |ro_key|
(1..5).each do |index|
day = HearingDay.create!(
regional_office: (ro_key == "C") ? nil : ro_key,
room: "1",
judge: User.find_by_css_id("BVAAABSHIRE"),
request_type: (ro_key == "C") ? "C" : "V",
scheduled_for: Time.zone.today + (index * 11).days,
created_by: user,
updated_by: user
)
case index
when 1
create_ama_hearing(day)
when 2
create_case_hearing(day, ro_key)
when 3
create_case_hearing(day, ro_key)
create_ama_hearing(day)
end
end
end

and have it fill up each hearing day, as opposed to just generating a 1-2 hearings for each day.

Copy link
Contributor

@jcq jcq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like it works locally, and seems like good code improvements in addition to GREAT performance improvements!

@@ -70,14 +70,19 @@ def warm_participant_caches

def warm_ro_participant_caches(ro_ids)
start_time = Time.zone.now
start_range = Time.zone.today.beginning_of_day
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for my own curiosity, which TZ would these be using? I haven't really looked at how we're storing/handling time data

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These would be using the UTC TZ in prod. It's slightly different in UAT because we have been testing some TZ changes there.

The web server does not run under UTC, which is a whole other story 🙁

@@ -0,0 +1,12 @@
# frozen_string_literal: true

module HearingTimeConcern
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good refactoring

@ferristseng ferristseng added the Ready-to-Merge This PR is ready to be merged and will be picked up by va-bot to automatically merge to master label Mar 12, 2020
@ferristseng ferristseng merged commit 7b13dd6 into master Mar 12, 2020
@pkarman pkarman deleted the ftseng-scheduled-veterans-performance branch March 31, 2020 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Product: caseflow-hearings Ready-to-Merge This PR is ready to be merged and will be picked up by va-bot to automatically merge to master Team: Tango 💃
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants