Skip to content

Commit

Permalink
feature/APPEALS-32376 (Release Candidate) (#22673)
Browse files Browse the repository at this point in the history
* APPEALS-36751 deleted set_time_zone.rb file

* APPEALS-37039 branch init.

* APPEALS-36751 deleted set_time_zone.rb file (#20493)

Co-authored-by: Matthew Thornton <99351305+ThorntonMatthew@users.noreply.github.com>

* APPEALS-36751 delete hearing_for_hearing_day_serializer.rb for code pruning

* APPEALS-37039 migrations made. up and down methods need to be completed.

* APPEALS-37039 migrations ran. schema updated.

* APPEALS-37039 applied expected fixes

* APPEALS-37039 schema changes.

* [APPEALS-36748] Passing timezone context during Schedule Veteran form submission

* [APPEALS-36748] Adding comments about timezone conversions

* [APPEALS-36748] Updating Hearing Time dropdown values

* [APPEALS-36748] Display Hearing Times in the correct timezone on the Daily Docket

* [APPEALS-36748] Fixing codeclimate errors

* APPEALS-37127 created new middleware class and spec file

* [APPEALS-36748] Fixing codeclimate and jest errors

* [APPEALS-36748] Fixing codeclimate and jest errors

* APPEALS-37127 added middleware to shoryuken file

* APPEALS-37561 new branch init. serializers updated.

* APPEALS-37561 spec/serializers/api/v2/hearing_serializer_spec.rb updated to test functionality with added attribute to serializer file.

* APPEALS-37127 switched to time.use_zone

* APPEALS-37039 branch init.

* APPEALS-37039 migrations made. up and down methods need to be completed.

* APPEALS-37039 migrations ran. schema updated.

* APPEALS-37039 applied expected fixes

* APPEALS-37039 schema changes.

* APPEALS-36751 deleted set_time_zone.rb file

* APPEALS-36751 delete hearing_for_hearing_day_serializer.rb for code pruning

* APPEALS-37561 new branch init. serializers updated.

* APPEALS-37561 spec/serializers/api/v2/hearing_serializer_spec.rb updated to test functionality with added attribute to serializer file.

* [APPEALS-36748] Fixing jest errors

* APPEALS-37127 updated rspec file, moved rspec file to correct directory, updated middleware file to always change timezone regardless

* APPEALS-37127 updated comment for middleware

* APPEALS-37095 branch init. New attribute added to factories/hearing.rb

* APPEALS-37095 New attribute added to factories/legacy_hearing.rb

* Add jest debugger

* [APPEALS-36748] Addressing PR feedback

* Update snapshot

* APPEALS-37127 fixed linter issues with method parameters

Co-authored-by: Matthew Thornton <99351305+ThorntonMatthew@users.noreply.github.com>

* APPEALS-37127 change use_zone call to fix rubocop issues

Co-authored-by: Matthew Thornton <99351305+ThorntonMatthew@users.noreply.github.com>

* [APPEALS-37094] Updating regional_office_timezone method

* APPEALS-37615 persisted scheduled_in_timezone attribute for ama and legacy hearings

* APPEALS-37615 schema update

* [APPEALS-37094] Fixing tests

* APPEALs-37095 2/02/24 EOD.Hearings Factory set for more dynamic info in regards to the timezone of the hearing.

* [APPEALS-37094] Fixing tests

* [APPEALS-37094] Updating snapshots

* APPEALS-37615 added rspec tests and bug fixes discovered from said tests

* [APPEALS-37094] Fixing tests

* Remove UAT block

* APPEALS-37615 failing rspec test fixes part 1

* [APPEALS-37094] Addressing PR feedback

* APPEALS-37095 Successfully updated both factories to dynamically produce appropriate values of timezones in relation to hearing locations.

* Update snapshot

* [APPEALS-37094] Addressing PR feedback

* APPEALS-37615 updated more rspec files to fix errors

* APPEALS-37615 removed byebug

* APPEALS-37095 working through fixing tests.

* Add some unit tests

* APPEALS-37615 made rubocop fixes and changed string to only have timezone

* APPEALS-37615 updated schema file to be same as feature branch's

* APPEALS-37615 removed newline that was messing things up

* APPEALS-37615 undo last commit

* APPEALS-37095 Tests in both models are now all passing. Going to add one more to keep context relevant in one of the legacy_hearing_spec tests.

* APPEALS-37095 additional test added to legacy_hearing_spec.

* Rubocop fixes

* A couple more Rubocop fixes

* More rubocop fixes

* APPEALS-37095 made adjustments per TL comments

* Revert "Rubocop fixes"

This reverts commit 18018fa.

* Fix spacing

* Add back in Rubocop fix

* Add back in another Rubocop fix

* Wmedders21/appeals 37096 (#21823)

* Use new db timezone comlumn value unless it is nil

* update comments to reflect new functionality

* Update test expectations to follow new functionality

* include missing schema update

* add spaces for readability

* Piedram/appeals 39890 (#21879)

* skip the functionality from this spec

* modified spec

* Wmedders21/appeals 37040 (#21890)

* Fix: incorrect proptype causing error in console

* Feature: HearingTimeScheduledInTimezone

* Render HearingTimeScheduledInTimezone if scheduledInTimezone value exists

* Add style to stylesheet instead of using glamor css

* Update jest snapshot

* Remove px for lint error

* ETL Migration scheduled_in_timezone on hearings (#21952)

* ETL Migration scheduled_in_timezone on hearings

* Change to inherit from caseflow migration

* APPEALS-39997 spec fixes (#21845)

* APPEALS-39997 spec fixes

* APPEALS-39997 spec fix in build_hearsched_spec

* APPEALS-39997 fix schedule time string

* Appeals-39997 spec fix in virtual hearing time slots

---------

Co-authored-by: Jim Foley <james.foley4@va.gov>

* Wmedders21/appeals 49036 (#21990)

* Add scheduled_in_timezone to mirrored_hearing_attributes

* Refactor status string to fit within 32 char limit set by appeals table on ETL schema

* Add expections to include scheduled_in_timezone in ETL hearing records

---------

Co-authored-by: Jim Foley <james.foley4@va.gov>

* Piedram/appeals 37103 (#21997)

* update jest and stories tets

* remove space

* remove empty line

---------

Co-authored-by: Jim Foley <james.foley4@va.gov>

* APPEALS-49793 rspec fix in hearing repository and filled hearing slot controller (#22026)

* Fix test flakiness due to async banners not being found by capybara a… (#22035)

* Fix test flakiness due to async banners not being found by capybara and dropdown selector strings.

* Test fix: Reload hearing before sending to method

* Test fix: Reload virtual_hearing before sending to method

* Test fix: use wait to allow db transaction to process

* Test fix - move links check to the end to allow time for db transaction to process

* APPEALS-50289 rspec fix in assign hearing disposition task spec (#22048)

Co-authored-by: Jim Foley <james.foley4@va.gov>

* Update shoryuken.rb

remove merge conflict message

* fix hearing_mailer.rb (#22065)

* Wmedders21/appeals 50767 (#22091)

* Fixed TimeSlot test

* update comment in test

* fix schedule veteran form test

* fix jest test from erroring out

* APPEALS-37051 ETLBuilderJob test data for hearings (#22118)

Co-authored-by: Jim Foley <james.foley4@va.gov>

* Process scheduled_time_string before creating a hearing via ScheduleHearingTask (#22152)

* Process scheduled_time_string before creating a hearing via ScheduleHearingTask

* Push up legacy time formatting fix

* Separate time object and original time string

* Centralize scheduled_time_string processing

* Unprivatize method

* Set expectation back

---------

Co-authored-by: Matthew Thornton <ThorntonMatthew@users.noreply.github.com>

* APPEALS-51555 (BUG): Hearing Time Options Not Reflecting Persisted Values (#22184)

* pushing up

* cleaning up code

* pushing up

* pushing up

* rubocopn

* fixing rspec tests

* fixing rspec tests

* pushing tests

* rubocop

* Lint roll

* Remove zero padding from times

* Remove hardcoded tz

* Test fixes

* Fix expected error class

* Fix unrelated failing test

---------

Co-authored-by: nhansen3 <noah.hansen1323@gmail.com>
Co-authored-by: Matthew Thornton <99351305+ThorntonMatthew@users.noreply.github.com>
Co-authored-by: Matthew Thornton <ThorntonMatthew@users.noreply.github.com>

* APPEALS-51447 Scheduled time showed in the left view is updated (#22162)

* APPEALS-51447 Scheduled time showed in the left view is updated

* Jest test fix in HearingTimeScheduledInTimezone

* APPEALS-51447 Add date to time conversion

* APPEALS-51447 Jest and Rspec fixed

---------

Co-authored-by: Jim Foley <james.foley4@va.gov>

* Create rake task to seed UAT (#22317)

* Create rake task to seed UAT

* change how to get the user and the veterant file_number

---------

Co-authored-by: Matthew Thornton <99351305+ThorntonMatthew@users.noreply.github.com>

* Create a Rails Migration to Add a 'scheduled_datetime'  (#22408)

* Create a Rails Migration to Add a 'scheduled_datetime' Column of Type timestamptz to the Postgres hearing Table

* include the schema.rb file

* Change comment in the migration

* Wmedders21/appeals 53522 (#22412)

* Test: Hearings::TimeService

* New service: Hearings::TimeService

* Add YARD documentation to  Hearings::TimeService

* Fix test expectation for no dst offset in winter

* Rename Hearings::TimeService to HearingDatetimeService

* Rubocop fixes in hearing_datetime_service_spec.rb

* Update HearingDatetimeService comments and spec expectations

* Add DST edge case testing for hearing datetime service

* Refactor prepare_time_for_storage to follow DRY

* Create rake task to seed UAT-Legacy (#22346)

* Create rake task to seed UAT-Legacy

* fix lint errors

* Change the user to work in UAT

* Modified file to run in UAT

* Fix the type of appeals and lint errors

* Changes needed to execute in UAT

* fix lint error in Seed AMA appeal

* Change parameter in function

* Update lib/tasks/seed_legacy_hearing.rake

---------

Co-authored-by: Matthew Thornton <99351305+ThorntonMatthew@users.noreply.github.com>

* APPEALS-53674 scheduled_for is Able to Account for scheduled_in_timez… (#22447)

* APPEALS-53674 scheduled_for is Able to Account for scheduled_in_timezone Values

* APPEALS-53674 spec coverage

* APPEALS-53674 updated spec

* Update app/models/hearing.rb

---------

Co-authored-by: Matthew Thornton <99351305+ThorntonMatthew@users.noreply.github.com>

* Wmedders21/appeals 53660 (#22431)

* LegacyHearing#scheduled_for WIP

* Define scheduled_for in legacy hearing and update hearing_day_id_refers_to_vacols_row? to prevent infinite loop

* Change legacy hearing factory to not supply scheduled_in_timezone by default

* Test: LegacyHearing #scheduled_for

* Rubocop style fixes

* Add YARD documentation to LegacyHearing#scheduled_for

* spec fixes

* revert to feature branch

* fix spec after changes to legacy hearing factory

* update spec for code changes in legacy appeal scheduled_for

* update spec to mock hearing more accurately

* rubocop fixes

---------

Co-authored-by: Matthew Thornton <99351305+ThorntonMatthew@users.noreply.github.com>

* Wmedders21/appeals 53688 (#22435)

* Add instance methods to HearingDatetimeService

* Rubocop fixes

* Add YARD documentation to instance methods

* Reformat HearingDatetimeService#central_office_timestring to match HearingTimeService#central_office_time_string

* add validation for scheduled_in_timezone

* update tests for validations and testing on different hearing days

* rubocop fixes

---------

Co-authored-by: Matthew Thornton <99351305+ThorntonMatthew@users.noreply.github.com>

* APPEALS-53536 new method to check the hearing date time service and h… (#22418)

* APPEALS-53536 new method to check the hearing date time service and hearing time service

* APPEALS-53536 added YARD Doc

* APPEALS-53536 scheduled_in_timezone nil by default in hearing and legacy hearing factories

* APPEALS-53536 spec fixes

* APPEASL-53536 YARD doc formatting

* Retriggering CI

* Update app/models/legacy_hearing.rb

* Update spec/models/hearing_spec.rb

---------

Co-authored-by: Matthew Thornton <99351305+ThorntonMatthew@users.noreply.github.com>
Co-authored-by: Matthew Thornton <ThorntonMatthew@users.noreply.github.com>

* Wmedders21/appeals 54461 (#22487)

* Add poa_time and appellant_time to HearingTimeConcern

* Replace HearingTimeService #poa_time and #appellant_time with HearingTimeConcern versions

* rubocop fixes

* update yard comments

* Remove outdated test from hearing_time_service_spec

* Adjust slot_hearing in HearingRepository to Utilize New HearingDateti… (#22491)

* Adjust slot_hearing in HearingRepository to Utilize New HearingDatetimeService

* fix lint errors

* Revert 'Schedule Veteran For A Hearing' expected times to what they are in master

* remove convert_scheduled_time_to_utc function, fix lint error and refactor some code

* Update spec/services/hearing_time_service_spec.rb

---------

Co-authored-by: Matthew Thornton <99351305+ThorntonMatthew@users.noreply.github.com>
Co-authored-by: Matthew Thornton <ThorntonMatthew@users.noreply.github.com>

* Update spec to use scheduled_in_timezone and scheduled_datetime

* Rubocop fix

* APPEALS-54170 Conditional Pre-Processing of scheduled_time_strings in HearingUpdateForm

* Change central office time string to always be in eastern time explicitly

* update Hearing#scheduled_for to have correct fallback logic

* revert expectation in daily_docket/build_hearsched_spec 'User can update fields'

* revert specs in hearing_mailer_spec

* revert spec changes

* revert spec changes

* MattT/APPEALS-54184: Introduce Conditional Pre-Processing of scheduled_time_strings in LegacyHearingUpdateForm (#22478)

* Set legacy hearing time updates to be processed by the HearingDatetimeService

* Remove unnecessary attr

* Fix attr name

* Build facade for processing incoming hearing time updates

* Update YARD docstring

* Some temp fix that will be replaced with future work

* Fix method names for tests

* Remove accidental change

* Remove tests for methods that no longer exist

* Add HearingTimeService#process_legacy_scheduled_time_string specs

* Remove problematic type since it's going away anyways

* Introduce some funky feature tests

* Fix recursive factory call

* Change expectations of tests to be more easily matched

* Fix feature tests

* Add a unit test

* Fix failing spec

* Fix flakey tests

* Update hearings seed

* Adjust hearing times in seed file

* Fix HearingDispositionChangeJob spec

---------

Co-authored-by: Matthew Thornton <ThorntonMatthew@users.noreply.github.com>

* Reconfigure placement of some methods. Reintroduce old Hearing#scheduled_for method

* Unskip a test

* Ooops! It needs to be a class method

* Fix typo

* Fix test

* Fix a silly spec typo

* Fix hearing_Spec

* MattT/APPEALS-53800: Replace all instances of 'America/Anchorage' with 'America/Juneau' (#22507)

* Replace all instances of 'America/Anchorage' with 'America/Juneau'

* Replace all instances of 'America/Anchorage' with 'America/Juneau'

* Update snapshots

---------

Co-authored-by: Matthew Thornton <ThorntonMatthew@users.noreply.github.com>

* Fix HearingTime offset on Schedule Veteran form

* Fix TimeSlot offsets when scheduling virtual hearings

* Fixes how offsets are displayed in the following areas:

Appellant TZ + Representative TZ dropdowns
Email Confirmation Modal
Daily Docket page dropdowns
Virtuah Hearing Conversion Form
Add Hearing Day page
Edit Docket page

* Push up some stragglers

* fix showing CORS errors on the frontend in development instead of the javascript error

* Fix DocketStartTimes offsets

* Fix VSO participant section timezone dropdowns

* Fix Storybook file

* Update spec to use scheduled_in_timezone and scheduled_datetime (#22502)

* Update spec to use scheduled_in_timezone and scheduled_datetime

* Rubocop fix

* Change central office time string to always be in eastern time explicitly

* update Hearing#scheduled_for to have correct fallback logic

* revert expectation in daily_docket/build_hearsched_spec 'User can update fields'

* revert specs in hearing_mailer_spec

* revert spec changes

* revert spec changes

* Update app/models/hearing.rb

Co-authored-by: Stephen E Baier <19843225+kilian-prime@users.noreply.github.com>

---------

Co-authored-by: Matthew Thornton <99351305+ThorntonMatthew@users.noreply.github.com>
Co-authored-by: Stephen E Baier <19843225+kilian-prime@users.noreply.github.com>

* Kamalam7/appeals 54170 (#22516)

* APPEALS-54170 spec fix

* APPEALS-54170 Add nil return type in YARD doc

* Fix test

---------

Co-authored-by: Matthew Thornton <99351305+ThorntonMatthew@users.noreply.github.com>
Co-authored-by: Matthew Thornton <ThorntonMatthew@users.noreply.github.com>

* Address some Storybook issues

* Remove accidental code additions

* Add back in missing code

* Fix linting error

* Add buildDatetimeString function

* Utilize buildDatetimeString function

* Add jsdoc param

* The juice was not worth the squeeze

* Revert other change too

* Fix radio field options in DocketStartTimes

* Fix test

* Fix fields on Hearing Details page

* Update Field.test.js

* Update snapshot temporarily

* Fix snapshots for Timezone

* Lint fix

* Update modalForms/HearingTime snapshots

* Fix TimeSlotButton tests

* Fix TimeSlot tests

* Fix AppellantSection tests and snapshots

* Fix rep section tests

* Fix DocketStartTimes tests

* Fix Fields tests

* Fix DailyDocketRow tests

* Fix EmailConfirmationModal tests

* Fix Timezone tests

* Fix CaseWorkerIndex snapshot

* Remove extra space

* Update ScheduleVeteranForm tests

* Add back in the newline

* Add spaces back in

* Add one more space

* Remove 3 spaces

* Add debugging output for CI troubleshooting

* Fix PropType issues

* Adjust expectation in Fields.test.js

* Alter expectations

* Revert tests

* Resolve double alert banners on Case Details page

* Add RO times to Previously Scheduled section of Daily Docket pages (#22649)

Co-authored-by: Matthew Thornton <ThorntonMatthew@users.noreply.github.com>

* MattT/APPEALS-56861 (#22650)

* Add RO times to Previously Scheduled section of Daily Docket pages

* Use RO tz over complex logic

* Update snapshot

---------

Co-authored-by: Matthew Thornton <ThorntonMatthew@users.noreply.github.com>

* Prototype/recipient timezone fallback (#22568)

* Update recipient timezone to look through appeal if nil elsewhere

* Remove redundant conditional from serializers and always pass representative_tz

* Refactor for readability

* update hearing mailer spec to account for recipient timezone fallback logic

* remove empty line

---------

Co-authored-by: Matthew Thornton <99351305+ThorntonMatthew@users.noreply.github.com>

* Revert "MattT/APPEALS-56861 (#22650)"

This reverts commit 08c9528.

* Remove duplicate line

* Sort by scheduled_for instead on Assign Hearings page (#22674)

* Sort by scheduled_for instead on Assign Hearings page

* Update snapshot

---------

Co-authored-by: Matthew Thornton <ThorntonMatthew@users.noreply.github.com>

* Address failures in spec

* Lint fix

---------

Co-authored-by: j-n-t-l <611441@bah.com>
Co-authored-by: Jonathan Cohen <cohen_jonathan@bah.com>
Co-authored-by: Janet Lu <93942793+j-n-t-l@users.noreply.github.com>
Co-authored-by: Prerna Devulapalli <prerna.devulapalli@va.gov>
Co-authored-by: Matthew Thornton <ThorntonMatthew@users.noreply.github.com>
Co-authored-by: prernadevbah <132498915+prernadevbah@users.noreply.github.com>
Co-authored-by: Will Medders <93014155+wmedders21@users.noreply.github.com>
Co-authored-by: piedram <110848569+piedram@users.noreply.github.com>
Co-authored-by: Jim Foley <james.foley4@va.gov>
Co-authored-by: Kamala Madamanchi <110078646+kamala-07@users.noreply.github.com>
Co-authored-by: msteele <Marc.Steele@va.gov>
Co-authored-by: noahhansen-gov <166541737+noahhansen-gov@users.noreply.github.com>
Co-authored-by: nhansen3 <noah.hansen1323@gmail.com>
Co-authored-by: William Medders <medders_william@bah.com>
Co-authored-by: Kamala Madamanchi <kamala.madamanchi@va.gov>
Co-authored-by: Clay Sheppard <csheepy@gmail.com>
Co-authored-by: Stephen E Baier <19843225+kilian-prime@users.noreply.github.com>
  • Loading branch information
18 people authored and AdamShawBAH committed Sep 9, 2024
1 parent dc5736f commit 47bc31b
Show file tree
Hide file tree
Showing 135 changed files with 88,403 additions and 86,590 deletions.
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@
"webpack:///*": "${webRoot}/*"
}
},
{
"name": "Jest - On Current File",
"type": "node",
"request": "launch",
"env": {
"NODE_ENV": "test"
},
"program": "${workspaceFolder}/client/node_modules/.bin/jest",
"args": [
"${relativeFile}"
],
"cwd": "${workspaceRoot}/client",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
],
"compounds": [
{
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/tasks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def update
# and AssignHearingDispositionTask for virtual hearing related updates
# Start with any alerts on the current task, then find alerts on the tasks
# that resulted from the update
alerts = tasks.reduce(task.alerts) { |acc, t| acc + t.alerts }
alerts = tasks.reduce([]) { |acc, t| acc + t.alerts }

tasks_hash[:alerts] = alerts if alerts # does not add to hash if alerts == []

Expand Down
4 changes: 2 additions & 2 deletions app/helpers/hearings/calendar_template_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ def central_office_display_time(hearing)
end

def representative_display_time(hearing)
format_hearing_time(hearing.time.poa_time)
format_hearing_time(hearing.poa_time)
end

def appellant_display_time(hearing)
format_hearing_time(hearing.time.appellant_time)
format_hearing_time(hearing.appellant_time)
end

# time_zone is a TZInfo::DataTimezone object; date_time_utc is a Time object
Expand Down
11 changes: 0 additions & 11 deletions app/jobs/application_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,6 @@ def capture_exception(error:, extra: {})
end
end

# Testing America/New_York TZ for all jobs in UAT.
# :nocov:
if Rails.deploy_env?(:uat)
around_perform do |_job, block|
Time.use_zone(Rails.configuration.time_zone) do
block.call
end
end
end
# :nocov:

before_perform do
if self.class.app_name.present?
RequestStore.store[:application] = "#{self.class.app_name}_job"
Expand Down
15 changes: 15 additions & 0 deletions app/jobs/middleware/job_time_zone_middleware.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

# This middleware ensures all async jobs run in UTC.
class JobTimeZoneMiddleware
# :reek:LongParameterList
def call(_worker, _queue, _msg, body, &block)
job_class = body["job_class"]
current_tz = Time.zone.name
if current_tz != "UTC"
Rails.logger.info("#{job_class} current timezone is #{current_tz}")
end

Time.use_zone("UTC", &block)
end
end
10 changes: 5 additions & 5 deletions app/mailers/hearing_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ def calendar_invite_name
end
end

def formatted_time
def formatted_time(time)
# Mon, Oct 19 at 10:30am CDT
time_format = "%a, %b %-d at %-l:%M%P %Z"
@hearing.time.appellant_time.strftime(time_format)
time.strftime(time_format)
end

def appellant_name
Expand All @@ -137,9 +137,9 @@ def appellant_last_name

def reminder_subject
if recipient_info.title == HearingEmailRecipient::RECIPIENT_TITLES[:representative]
"Reminder: #{appellant_name}'s Board hearing is #{formatted_time} – Do Not Reply"
"Reminder: #{appellant_name}'s Board hearing is #{formatted_time(@hearing.poa_time)} – Do Not Reply"
else
"Reminder: Your hearing is #{formatted_time} – Do Not Reply"
"Reminder: Your hearing is #{formatted_time(@hearing.appellant_time)} – Do Not Reply"
end
end

Expand All @@ -149,7 +149,7 @@ def confirmation_subject
when HearingEmailRecipient::RECIPIENT_TITLES[:appellant]
"Your Board hearing has been scheduled – Do Not Reply"
when HearingEmailRecipient::RECIPIENT_TITLES[:representative]
"Confirmation: #{appellant_last_name}'s Board hearing is #{formatted_time} – Do Not Reply"
"Confirmation: #{appellant_last_name}'s Board hearing is #{formatted_time(@hearing.poa_time)} – Do Not Reply"
when HearingEmailRecipient::RECIPIENT_TITLES[:judge]
hearing_date = virtual_hearing.hearing.scheduled_for.to_formatted_s(:short_date)

Expand Down
2 changes: 1 addition & 1 deletion app/mappers/hearing_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class << self
def hearing_fields_to_vacols_codes(hearing_info)
{
request_type: validate_request_type(hearing_info[:request_type], hearing_info.keys),
scheduled_for: VacolsHelper.format_datetime_with_utc_timezone(hearing_info[:scheduled_for]),
scheduled_for: hearing_info[:scheduled_for],
notes: notes_to_vacols_format(hearing_info[:notes]),
disposition: disposition_to_vacols_format(hearing_info[:disposition], hearing_info.keys),
hold_open: hold_open_to_vacols_format(hearing_info[:hold_open]),
Expand Down
10 changes: 6 additions & 4 deletions app/models/concerns/has_hearing_email_recipients_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ def appellant_email_address

def appellant_tz
recipient = email_recipients.find_by(type: "AppellantHearingEmailRecipient")
return recipient.timezone if recipient.present?
return virtual_hearing[:appellant_tz] if virtual_hearing.present?
recipient&.timezone ||
virtual_hearing&.[](:appellant_tz) ||
appeal&.appellant_tz
end

def representative_email_address
Expand All @@ -127,8 +128,9 @@ def representative_email_address

def representative_tz
recipient = email_recipients.find_by(type: "RepresentativeHearingEmailRecipient")
return recipient.timezone if recipient.present?
return virtual_hearing[:representative_tz] if virtual_hearing.present?
recipient&.timezone ||
virtual_hearing&.[](:representative_tz) ||
appeal&.representative_tz
end

private
Expand Down
39 changes: 38 additions & 1 deletion app/models/concerns/hearing_time_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,44 @@ module HearingTimeConcern
delegate :central_office_time_string, :scheduled_time_string,
to: :time

# A façade for a hearing's memoized time service instance - either {HearingTimeService} or {HearingDatetimeService},
# depending on the hearing's attributes.
#
# @return [HearingTimeService] if {Hearing#use_hearing_datetime?} or {LegacyHearing#use_hearing_datetime?} is false
# @return [HearingDatetimeService] if {Hearing#use_hearing_datetime?} or {LegacyHearing#use_hearing_datetime?} is true
def time
@time ||= HearingTimeService.new(hearing: self)
@time ||= if use_hearing_datetime?
HearingDatetimeService.new(hearing: self)
else
HearingTimeService.new(hearing: self)
end
end

# The hearing's local time cast into the POA's timezone
#
# @return [Time]
# The hearing time in the representative recipient's timezone, if available, else local time.
def poa_time
normalized_time(representative_tz)
end

# The hearing's local time cast into the appellant's timezone
#
# @return [Time]
# The hearing time in appellant recipient's timezone, if available, else local time.
def appellant_time
normalized_time(appellant_tz)
end

private

# @param timezone [String] A timezone in a format readable by Rails ActiveSupport::TimeZone.
#
# @return [Time] The hearing's local time cast into the supplied timezone.
# @return [Time] Fall back to the hearing's default local time if the supplied timezone is nil.
def normalized_time(timezone)
return time.local_time if timezone.nil?

time.local_time.in_time_zone(timezone)
end
end
1 change: 1 addition & 0 deletions app/models/etl/hearing_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def mirrored_hearing_attributes
:notes,
:prepped,
:representative_name,
:scheduled_in_timezone,
:scheduled_time,
:summary,
:transcript_requested,
Expand Down
23 changes: 19 additions & 4 deletions app/models/hearing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,21 @@ def advance_on_docket_motion
.first
end

# returns scheduled datetime object considering the timezones
# @return [nil] if hearing_day is nil
# @return [Time] in scheduled_in_timezone timezone - if scheduled_datetime and scheduled_in_timezone are present
# @return [Time] else datetime in regional office timezone
# rubocop:disable Metrics/AbcSize
def scheduled_for
return nil unless hearing_day

# returns datetime in scheduled_in_timezone timezone
if scheduled_datetime.present? && scheduled_in_timezone.present?
return scheduled_datetime.in_time_zone(scheduled_in_timezone)
end

# returns the date and time a hearing is scheduled for in the regional office's
# time zone
#
# When a hearing is scheduled, we save the hearing time to the scheduled_time
# field. The time is converted to UTC upon save *relative to the timezone of
# the user who saved it*, not relative to the timezone of the RO where the
Expand All @@ -211,7 +220,6 @@ def scheduled_for
# to explicitly convert it to the time zone of the person who scheduled it,
# then assemble and return a TimeWithZone object cast to the regional
# office's time zone.

updated_by_timezone = updated_by&.timezone || Time.zone.name
scheduled_time_in_updated_by_timezone = scheduled_time.utc.in_time_zone(updated_by_timezone)

Expand All @@ -226,11 +234,18 @@ def scheduled_for
)
end
end
# rubocop:enable Metrics/AbcSize

def scheduled_for_past?
scheduled_for < DateTime.yesterday.in_time_zone(regional_office_timezone)
end

# Checks the scheduled_datetime value and returns
# @return [Boolean] true if scheduled_datetime is not nil, else false
def use_hearing_datetime?
scheduled_datetime.present?
end

def worksheet_issues
request_issues.map do |request_issue|
HearingIssueNote.joins(:request_issue)
Expand All @@ -240,10 +255,10 @@ def worksheet_issues

def regional_office
@regional_office ||= begin
RegionalOffice.find!(regional_office_key)
RegionalOffice.find!(regional_office_key)
rescue RegionalOffice::NotFoundError
nil
end
end
end

def regional_office_key
Expand Down
6 changes: 5 additions & 1 deletion app/models/hearings/forms/hearing_update_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ def hearing_updates
prepped: prepped,
representative_name: representative_name,
room: room,
scheduled_time: scheduled_time_string,
scheduled_time: HearingTimeService.process_scheduled_time(scheduled_time_string),
scheduled_datetime: hearing.time.class.prepare_datetime_for_storage(
date: hearing.hearing_day&.scheduled_for,
time_string: scheduled_time_string
),
summary: summary,
transcript_requested: transcript_requested,
transcript_sent_date: transcript_sent_date,
Expand Down
12 changes: 7 additions & 5 deletions app/models/hearings/forms/legacy_hearing_update_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ def after_update_hearing

private

# rubocop:disable Metrics/MethodLength
def hearing_updates
updates = {
{
aod: aod,
bva_poc: bva_poc,
disposition: disposition,
Expand All @@ -35,14 +36,15 @@ def hearing_updates
prepped: prepped,
representative_name: representative_name,
room: room,
scheduled_for: scheduled_for,
scheduled_time_string: scheduled_time_string,
scheduled_for: hearing.time.process_legacy_scheduled_time_string(
date: hearing.hearing_day&.scheduled_for,
time_string: scheduled_time_string
),
summary: summary,
transcript_requested: transcript_requested,
witness: witness,
email_recipients_attributes: email_recipients_attributes
}.compact

HearingTimeService.build_legacy_params_with_time(hearing, updates)
end
# rubocop:enable Metrics/MethodLength
end
29 changes: 27 additions & 2 deletions app/models/legacy_hearing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,10 @@ def external_id
end

def hearing_day_id_refers_to_vacols_row?
(original_request_type == HearingDay::REQUEST_TYPES[:central] && scheduled_for.to_date < Date.new(2019, 1, 1)) ||
(original_request_type == HearingDay::REQUEST_TYPES[:video] && scheduled_for.to_date < Date.new(2019, 4, 1))
perform_vacols_request unless @vacols_load_status == :success

(original_request_type == HearingDay::REQUEST_TYPES[:central] && @scheduled_for.to_date < Date.new(2019, 1, 1)) ||
(original_request_type == HearingDay::REQUEST_TYPES[:video] && @scheduled_for.to_date < Date.new(2019, 4, 1))
end

def hearing_day_id
Expand Down Expand Up @@ -207,6 +209,12 @@ def scheduled_for_past?
scheduled_date < DateTime.yesterday.in_time_zone(regional_office_timezone)
end

# Checks the scheduled_in_timezone value and returns
# @return [Boolean] true if scheduled_in_timezone is not nil, else false
def use_hearing_datetime?
scheduled_in_timezone.present?
end

def held_open?
hold_open && hold_open > 0
end
Expand Down Expand Up @@ -360,6 +368,23 @@ def vacols_hearing_exists?
end
end

# The scheduled time for a legacy hearing after it have been retrieved from VACOLS and processed for time zone.
#
# @return [Time] a Time object in the calculated time zone and DST offset
def scheduled_for
perform_vacols_request unless @vacols_load_status == :success

return nil unless @scheduled_for

return @scheduled_for.in_time_zone(scheduled_in_timezone) if scheduled_in_timezone

HearingMapper.datetime_based_on_type(
datetime: @scheduled_for,
regional_office: HearingRepository.regional_office_for_scheduled_timezone(self, vacols_record),
type: vacols_record.hearing_type
)
end

class << self
def venues
RegionalOffice::CITIES.merge(RegionalOffice::SATELLITE_OFFICES)
Expand Down
Loading

0 comments on commit 47bc31b

Please sign in to comment.