From 8a298dcc062566ee5ff45bd996ac638875bff11e Mon Sep 17 00:00:00 2001 From: Tonksthebear Date: Wed, 11 Dec 2024 11:31:16 -0800 Subject: [PATCH 1/3] Remove duplicate code and update timezone window --- config/features.yml | 3 --- .../services/mobile/v2/appointments/proxy.rb | 5 ----- .../mobile/v0/appointments/vaos_v2_spec.rb | 1 - .../v2/appointments_presentation_filter.rb | 2 +- .../services/vaos/v2/appointments_service.rb | 17 ++++++++--------- .../spec/requests/vaos/v2/appointments_spec.rb | 1 - .../services/v2/appointment_service_spec.rb | 18 ------------------ 7 files changed, 9 insertions(+), 38 deletions(-) diff --git a/config/features.yml b/config/features.yml index 7cf881f90ae..9b46026d52b 100644 --- a/config/features.yml +++ b/config/features.yml @@ -31,9 +31,6 @@ features: actor_type: user description: Enables enhancement to the 21-526EZ "Add Disabilities" page being implemented by the Conditions Team. enable_in_development: true - appointments_consolidation: - actor_type: user - description: For features being tested while merging logic for appointments between web and mobile ask_va_form_feature: actor_type: user description: show/hide experimental features for Ask VA 0873 diff --git a/modules/mobile/app/services/mobile/v2/appointments/proxy.rb b/modules/mobile/app/services/mobile/v2/appointments/proxy.rb index 5909538667e..083f88e3103 100644 --- a/modules/mobile/app/services/mobile/v2/appointments/proxy.rb +++ b/modules/mobile/app/services/mobile/v2/appointments/proxy.rb @@ -22,11 +22,6 @@ def get_appointments(start_date:, end_date:, include_pending:, pagination_params appointments = response[:data] - unless Flipper.enabled?(:appointments_consolidation, @user) - filterer = VAOS::V2::AppointmentsPresentationFilter.new - appointments = appointments.keep_if { |appt| filterer.user_facing?(appt) } - end - appointments = vaos_v2_to_v0_appointment_adapter.parse(appointments) [appointments.sort_by(&:start_date_utc), response[:meta][:failures]] diff --git a/modules/mobile/spec/requests/mobile/v0/appointments/vaos_v2_spec.rb b/modules/mobile/spec/requests/mobile/v0/appointments/vaos_v2_spec.rb index 36404c00e0c..10faf2dec26 100644 --- a/modules/mobile/spec/requests/mobile/v0/appointments/vaos_v2_spec.rb +++ b/modules/mobile/spec/requests/mobile/v0/appointments/vaos_v2_spec.rb @@ -10,7 +10,6 @@ let!(:user) { sis_user(icn: '1012846043V576341', vha_facility_ids: [402, 555]) } before do - Flipper.enable_actor(:appointments_consolidation, user) Flipper.disable(:va_online_scheduling_vaos_alternate_route) end diff --git a/modules/vaos/app/services/vaos/v2/appointments_presentation_filter.rb b/modules/vaos/app/services/vaos/v2/appointments_presentation_filter.rb index 7ddac736261..2930c2d01f7 100644 --- a/modules/vaos/app/services/vaos/v2/appointments_presentation_filter.rb +++ b/modules/vaos/app/services/vaos/v2/appointments_presentation_filter.rb @@ -36,7 +36,7 @@ def presentable_requested_appointment?(appointment) return false unless created_at valid_appointment_request?(appointment) && appointment[:status].in?(%w[proposed cancelled]) && - created_at.between?(120.days.ago.beginning_of_day, 1.day.from_now.end_of_day) + created_at.between?(120.days.ago.beginning_of_day, 2.days.from_now.end_of_day) end def valid_appointment?(appointment) diff --git a/modules/vaos/app/services/vaos/v2/appointments_service.rb b/modules/vaos/app/services/vaos/v2/appointments_service.rb index bbcc57369b2..d7b68ea40a4 100644 --- a/modules/vaos/app/services/vaos/v2/appointments_service.rb +++ b/modules/vaos/app/services/vaos/v2/appointments_service.rb @@ -52,10 +52,8 @@ def get_appointments(start_date, end_date, statuses = nil, pagination_params = { cnp_count += 1 if cnp?(appt) end - if Flipper.enabled?(:appointments_consolidation, user) - filterer = AppointmentsPresentationFilter.new - appointments = appointments.keep_if { |appt| filterer.user_facing?(appt) } - end + filterer = AppointmentsPresentationFilter.new + appointments = appointments.keep_if { |appt| filterer.user_facing?(appt) } # log count of C&P appointments in the appointments list, per GH#78141 log_cnp_appt_count(cnp_count) if cnp_count.positive? @@ -65,8 +63,8 @@ def get_appointments(start_date, end_date, statuses = nil, pagination_params = { } end rescue Common::Client::Errors::ParsingError, Common::Client::Errors::ClientError, - Common::Exceptions::GatewayTimeout, MAP::SecurityToken::Errors::ApplicationMismatchError, - MAP::SecurityToken::Errors::MissingICNError => e + Common::Exceptions::GatewayTimeout, MAP::SecurityToken::Errors::ApplicationMismatchError, + MAP::SecurityToken::Errors::MissingICNError => e { data: {}, meta: pagination(pagination_params).merge({ @@ -98,14 +96,14 @@ def post_appointment(request_object_body) params.compact_blank! with_monitoring do response = if Flipper.enabled?(APPOINTMENTS_USE_VPG, user) && - Flipper.enabled?(APPOINTMENTS_ENABLE_OH_REQUESTS) + Flipper.enabled?(APPOINTMENTS_ENABLE_OH_REQUESTS) perform(:post, appointments_base_path_vpg, params, headers) else perform(:post, appointments_base_path_vaos, params, headers) end if request_object_body[:kind] == 'clinic' && - booked?(request_object_body) # a direct scheduled appointment + booked?(request_object_body) # a direct scheduled appointment modify_desired_date(request_object_body, get_facility_timezone(request_object_body[:location_id])) end @@ -126,7 +124,7 @@ def post_appointment(request_object_body) def update_appointment(appt_id, status) with_monitoring do if Flipper.enabled?(ORACLE_HEALTH_CANCELLATIONS, user) && - Flipper.enabled?(APPOINTMENTS_USE_VPG, user) + Flipper.enabled?(APPOINTMENTS_USE_VPG, user) update_appointment_vpg(appt_id, status) get_appointment(appt_id) else @@ -234,6 +232,7 @@ def parse_possible_token_related_errors(e) { message:, status:, icn: sanitized_icn, context: } end end + # rubocop:enable Metrics/MethodLength # Modifies the appointment, extracting individual fields from the appointment. This currently includes: diff --git a/modules/vaos/spec/requests/vaos/v2/appointments_spec.rb b/modules/vaos/spec/requests/vaos/v2/appointments_spec.rb index 892aed35ad1..72579159b2c 100644 --- a/modules/vaos/spec/requests/vaos/v2/appointments_spec.rb +++ b/modules/vaos/spec/requests/vaos/v2/appointments_spec.rb @@ -9,7 +9,6 @@ allow(Settings.mhv).to receive(:facility_range).and_return([[1, 999]]) Flipper.enable('va_online_scheduling') Flipper.disable(:va_online_scheduling_vaos_alternate_route) - Flipper.enable_actor('appointments_consolidation', current_user) sign_in_as(current_user) allow_any_instance_of(VAOS::UserService).to receive(:session).and_return('stubbed_token') end diff --git a/modules/vaos/spec/services/v2/appointment_service_spec.rb b/modules/vaos/spec/services/v2/appointment_service_spec.rb index 0300e8a5d83..c233973a7bb 100644 --- a/modules/vaos/spec/services/v2/appointment_service_spec.rb +++ b/modules/vaos/spec/services/v2/appointment_service_spec.rb @@ -58,7 +58,6 @@ before do allow_any_instance_of(VAOS::UserService).to receive(:session).and_return('stubbed_token') - Flipper.enable_actor(:appointments_consolidation, user) Flipper.disable(:va_online_scheduling_vaos_alternate_route) end @@ -429,23 +428,6 @@ end end - context 'when requesting a list of appointments containing a booked cc appointment' do - it 'sets cancellable to false' do - Flipper.disable(:appointments_consolidation) - allow_any_instance_of(VAOS::V2::MobileFacilityService).to receive(:get_facility!).and_return(mock_facility2) - VCR.use_cassette('vaos/v2/appointments/get_appointments_200_cc_booked', - allow_playback_repeats: true, match_requests_on: %i[method path query], tag: :force_utf8) do - response = subject.get_appointments(start_date2, end_date2) - expect(response[:data][0][:kind]).to eq('cc') - expect(response[:data][0][:status]).to eq('booked') - expect(response[:data][0][:cancellable]).to eq(false) - expect(response[:data][1][:kind]).to eq('cc') - expect(response[:data][1][:status]).to eq('booked') - expect(response[:data][1][:cancellable]).to eq(false) - end - end - end - context 'when requesting a list of appointments containing proposed or cancelled cc appointments' do it 'fetches provider info for a proposed cc appointment' do allow_any_instance_of(VAOS::V2::MobileFacilityService).to receive(:get_facility!).and_return(mock_facility2) From a4e1e2167460d4cfed750df65f5e0a0a5ce0a2dc Mon Sep 17 00:00:00 2001 From: Tonksthebear Date: Thu, 12 Dec 2024 10:12:56 -0800 Subject: [PATCH 2/3] Rubocop --- .../vaos/app/services/vaos/v2/appointments_service.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/vaos/app/services/vaos/v2/appointments_service.rb b/modules/vaos/app/services/vaos/v2/appointments_service.rb index d7b68ea40a4..fd7f0c98b8d 100644 --- a/modules/vaos/app/services/vaos/v2/appointments_service.rb +++ b/modules/vaos/app/services/vaos/v2/appointments_service.rb @@ -63,8 +63,8 @@ def get_appointments(start_date, end_date, statuses = nil, pagination_params = { } end rescue Common::Client::Errors::ParsingError, Common::Client::Errors::ClientError, - Common::Exceptions::GatewayTimeout, MAP::SecurityToken::Errors::ApplicationMismatchError, - MAP::SecurityToken::Errors::MissingICNError => e + Common::Exceptions::GatewayTimeout, MAP::SecurityToken::Errors::ApplicationMismatchError, + MAP::SecurityToken::Errors::MissingICNError => e { data: {}, meta: pagination(pagination_params).merge({ @@ -96,14 +96,14 @@ def post_appointment(request_object_body) params.compact_blank! with_monitoring do response = if Flipper.enabled?(APPOINTMENTS_USE_VPG, user) && - Flipper.enabled?(APPOINTMENTS_ENABLE_OH_REQUESTS) + Flipper.enabled?(APPOINTMENTS_ENABLE_OH_REQUESTS) perform(:post, appointments_base_path_vpg, params, headers) else perform(:post, appointments_base_path_vaos, params, headers) end if request_object_body[:kind] == 'clinic' && - booked?(request_object_body) # a direct scheduled appointment + booked?(request_object_body) # a direct scheduled appointment modify_desired_date(request_object_body, get_facility_timezone(request_object_body[:location_id])) end @@ -124,7 +124,7 @@ def post_appointment(request_object_body) def update_appointment(appt_id, status) with_monitoring do if Flipper.enabled?(ORACLE_HEALTH_CANCELLATIONS, user) && - Flipper.enabled?(APPOINTMENTS_USE_VPG, user) + Flipper.enabled?(APPOINTMENTS_USE_VPG, user) update_appointment_vpg(appt_id, status) get_appointment(appt_id) else From 139aa1f48816c6ccfb77f0657c2f9e4fa949e31c Mon Sep 17 00:00:00 2001 From: Tonksthebear Date: Thu, 12 Dec 2024 10:50:05 -0800 Subject: [PATCH 3/3] Fix test --- .../spec/services/v2/appointments_presentation_filter_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/vaos/spec/services/v2/appointments_presentation_filter_spec.rb b/modules/vaos/spec/services/v2/appointments_presentation_filter_spec.rb index 3fea28c5b46..729dfdf781e 100644 --- a/modules/vaos/spec/services/v2/appointments_presentation_filter_spec.rb +++ b/modules/vaos/spec/services/v2/appointments_presentation_filter_spec.rb @@ -60,8 +60,8 @@ def mock_appointment(id: nil, created: nil, status: nil, start: nil, requested_p expect(filterer.user_facing?(request)).to be false end - it 'returns false if it was created more than a day from now' do - request[:created] = 2.days.from_now.to_s + it 'returns false if it was created more than 2 days from now' do + request[:created] = 3.days.from_now.to_s expect(filterer.user_facing?(request)).to be false end