Skip to content

Commit

Permalink
Explicitly prefer BGS POA on cached appeals attributes (#13554)
Browse files Browse the repository at this point in the history
connects #13384 

### Description
We prefer displaying BGS POA name, so explicitly cache that. Otherwise, the `PowerOfAttorney` model will trigger loads of VACOLS `case_record` and `representative` that we will not use.

If BGS POA is not found, fall back to VACOLS.

In my manual tests in production, this greatly reduces calls to VACOLS, and instead shifts POA info to the BGS service (which is now cached for 30 days in Redis).
  • Loading branch information
pkarman authored Feb 28, 2020
1 parent d442168 commit 970320b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 4 additions & 1 deletion app/jobs/update_cached_appeals_attributes_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class UpdateCachedAppealsAttributesJob < CaseflowJob
include ActionView::Helpers::DateHelper

queue_with_priority :low_priority
application_attr :queue

APP_NAME = "caseflow_job"
METRIC_GROUP_NAME = UpdateCachedAppealsAttributesJob.name.underscore
Expand Down Expand Up @@ -101,14 +102,16 @@ def cache_legacy_appeals
def cache_legacy_appeal_postgres_data(legacy_appeals)
values_to_cache = legacy_appeals.map do |appeal|
regional_office = RegionalOffice::CITIES[appeal.closest_regional_office]
# bypass PowerOfAttorney model completely and always prefer BGS cache
bgs_poa = BgsPowerOfAttorney.new(file_number: appeal.veteran_file_number)
{
vacols_id: appeal.vacols_id,
appeal_id: appeal.id,
appeal_type: LegacyAppeal.name,
closest_regional_office_city: regional_office ? regional_office[:city] : COPY::UNKNOWN_REGIONAL_OFFICE,
closest_regional_office_key: regional_office ? appeal.closest_regional_office : COPY::UNKNOWN_REGIONAL_OFFICE,
docket_type: appeal.docket_name, # "legacy"
power_of_attorney_name: appeal.representative_name,
power_of_attorney_name: bgs_poa.representative_name || appeal.representative_name,
suggested_hearing_location: appeal.suggested_hearing_location&.formatted_location
}
end
Expand Down
4 changes: 1 addition & 3 deletions app/models/power_of_attorney.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
# and lets the user modify VACOLS with BGS information
# (but not the other way around).
#
# TODO: we query VACOLS when the vacols methods are
# called, even if we've also queried VACOLS outside of this
# model but in the same request. is this something we should optimize?

class PowerOfAttorney
include ActiveModel::Model
include AssociatedVacolsModel
Expand Down

0 comments on commit 970320b

Please sign in to comment.