Skip to content

Commit

Permalink
EDM-229/remove operating hours from sob (#19201)
Browse files Browse the repository at this point in the history
* Remove outdated code from post 911 controller

* Remove outdated methods from lighthouse service

* Remove outside working hours error

* Remove outside working hours

* Remove backend status show route and logic

* Remove backend status model and serializer

* Remove backend status factory

* Update swagger

* Update specs

* Fix linting

* Remove backend status from json and swagger spec

* Update codeowners

* Fix swagger spec

* Remove factories from codeowners
  • Loading branch information
jefftmarks authored Nov 1, 2024
1 parent 518ace1 commit 879216f
Show file tree
Hide file tree
Showing 18 changed files with 9 additions and 563 deletions.
4 changes: 0 additions & 4 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ app/models/async_transaction/va_profile @department-of-veterans-affairs/vfs-auth
app/models/async_transaction/vet360 @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/backend-review-group
app/models/attachment.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/models/average_days_for_claim_completion.rb @department-of-veterans-affairs/benefits-microservices @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/models/backend_status.rb @department-of-veterans-affairs/backend-review-group
app/models/bgs_dependents @department-of-veterans-affairs/benefits-dependents-management @department-of-veterans-affairs/backend-review-group @department-of-veterans-affairs/va-api-engineers
app/models/central_mail_claim.rb @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/models/central_mail_submission.rb @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
Expand Down Expand Up @@ -358,7 +357,6 @@ app/serializers/async_transaction @department-of-veterans-affairs/vfs-authentica
app/serializers/async_transaction/base_serializer.rb @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/serializers/attachment_serializer.rb @department-of-veterans-affairs/vfs-10-10 @department-of-veterans-affairs/backend-review-group @department-of-veterans-affairs/va-api-engineers
app/serializers/backend_statuses_serializer.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/serializers/backend_status_serializer.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/serializers/category_serializer.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/serializers/cemetery_serializer.rb @department-of-veterans-affairs/mbs-core-team @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/serializers/central_mail_submission_serializer.rb @department-of-veterans-affairs/backend-review-group
Expand Down Expand Up @@ -1151,7 +1149,6 @@ spec/factories/appeal_submission_uploads.rb @department-of-veterans-affairs/vfs-
spec/factories/ask.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/factories/async_transactions.rb @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/factories/attachments.rb @department-of-veterans-affairs/vfs-mhv-secure-messaging @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/factories/backend_statuses.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/factories/burial_claim.rb @department-of-veterans-affairs/mbs-core-team @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/factories/caregivers_assistance_claim.rb @department-of-veterans-affairs/vfs-10-10 @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/factories/central_mail_submissions.rb @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
Expand Down Expand Up @@ -1714,7 +1711,6 @@ spec/rswag_override.rb @department-of-veterans-affairs/va-api-engineers @departm
spec/serializers/appointment_serializer_spec.rb @department-of-veterans-affairs/vfs-vaos @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/serializers/async_transaction/base_serializer_spec.rb @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/serializers/attachment_serializer_spec.rb @department-of-veterans-affairs/vfs-10-10 @department-of-veterans-affairs/backend-review-group @department-of-veterans-affairs/va-api-engineers
spec/serializers/backend_status_serializer_spec.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/serializers/backend_statuses_serializer_spec.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/serializers/category_serializer_spec.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/serializers/central_mail_submission_serializer_spec.rb @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
Expand Down
26 changes: 0 additions & 26 deletions app/controllers/v0/backend_statuses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,12 @@ module V0
class BackendStatusesController < ApplicationController
service_tag 'maintenance-windows'
skip_before_action :authenticate
before_action :validate_service, only: [:show]

def index
options = { params: { maintenance_windows: } }
render json: BackendStatusesSerializer.new(backend_statuses, options)
end

# TO-DO: After transition of Post-911 GI Bill to 24/7 availability, confirm show action
# and related logic can be completely removed
#
# GET /v0/backend_statuses/:service
def show
render json: BackendStatusSerializer.new(backend_status)
end

private

# NOTE: Data is from PagerDuty
Expand All @@ -32,22 +23,5 @@ def backend_statuses
def maintenance_windows
@maintenance_windows ||= MaintenanceWindow.end_after(Time.zone.now)
end

# NOTE: Data is GI bill scheduled downtime
def backend_status
@backend_status ||= BackendStatus.new(name: backend_service)
end

def backend_service
params[:service]
end

def validate_service
raise Common::Exceptions::RecordNotFound, backend_service unless recognized_service?
end

def recognized_service?
BackendServices.all.include?(backend_service)
end
end
end
19 changes: 0 additions & 19 deletions app/controllers/v1/post911_gi_bill_statuses_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

require 'formatters/date_formatter'
require 'lighthouse/benefits_education/outside_working_hours'
require 'lighthouse/benefits_education/service'

module V1
Expand All @@ -10,9 +9,6 @@ class Post911GIBillStatusesController < ApplicationController
include SentryLogging
service_tag 'gibill-statement'

# TO-DO: Remove this action after transition of LTS to 24/7 availability
before_action :service_available?, only: :show

STATSD_GI_BILL_TOTAL_KEY = 'api.lighthouse.gi_bill_status.total'
STATSD_GI_BILL_FAIL_KEY = 'api.lighthouse.gi_bill_status.fail'

Expand All @@ -36,16 +32,6 @@ def handle_error(e)
render json: { errors: e.errors }, status: status || :internal_server_error
end

# TO-DO: Remove this method after transition of LTS to 24/7 availability
def service_available?
unless Flipper.enabled?(:sob_updated_design) || BenefitsEducation::Service.within_scheduled_uptime?
StatsD.increment(STATSD_GI_BILL_FAIL_KEY, tags: ['error:scheduled_downtime'])
headers['Retry-After'] = BenefitsEducation::Service.retry_after_time
# 503 response
raise BenefitsEducation::OutsideWorkingHours
end
end

def log_vet_not_found(user, timestamp)
PersonalInformationLog.create(
data: { timestamp:, user: user_json(user) },
Expand All @@ -69,11 +55,6 @@ def user_json(user)
}.to_json
end

# TO-DO: Remove this method after transition of LTS to 24/7 availability
def skip_sentry_exception_types
super + [BenefitsEducation::OutsideWorkingHours]
end

def service
BenefitsEducation::Service.new(@current_user&.icn)
end
Expand Down
37 changes: 0 additions & 37 deletions app/models/backend_status.rb

This file was deleted.

14 changes: 0 additions & 14 deletions app/serializers/backend_status_serializer.rb

This file was deleted.

38 changes: 0 additions & 38 deletions app/swagger/swagger/requests/backend_statuses.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,44 +87,6 @@ class BackendStatuses
end
end
end

swagger_path '/v0/backend_statuses/{service}' do
operation :get do
key :description, 'Gets the status of backend service'
key :operationId, 'getBackendStatus'
key :tags, %w[backend_statuses]

parameter do
key :name, 'service'
key :in, :path
key :description, 'The name of the backend service'
key :required, true
key :type, :string
key :enum, BackendServices.all
end

response 200 do
key :description, 'Response is OK'
schema do
key :$ref, :Availability
end
end
end
end

swagger_schema :Availability do
key :required, %i[data]
property :data, type: :object do
key :required, %i[attributes]
property :id, type: :string
property :type, type: :string
property :attributes, type: :object do
key :required, %i[name is_available]
property :is_available, type: :boolean, example: true
property :name, type: :string, example: 'gibs'
end
end
end
end
end
end
7 changes: 0 additions & 7 deletions config/locales/exceptions.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2247,13 +2247,6 @@ en:
<<: *defaults
code: LH_gateway_timeout
status: 504
benefits_education:
outside_working_hours:
<<: *defaults
title: External service unavailable
detail: 'Lighthouse GI Bill Status is not available outside of working hours'
code: 114
status: 503
evss:
external_service_unavailable:
<<: *defaults
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@
get 'profile/mailing_address', to: 'addresses#show'
put 'profile/mailing_address', to: 'addresses#update'

resources :backend_statuses, param: :service, only: %i[index show]
resources :backend_statuses, only: %i[index]

resources :apidocs, only: [:index]

Expand Down
27 changes: 0 additions & 27 deletions lib/lighthouse/benefits_education/outside_working_hours.rb

This file was deleted.

60 changes: 0 additions & 60 deletions lib/lighthouse/benefits_education/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@ class Service < Common::Client::Base

STATSD_KEY_PREFIX = 'api.benefits_education'

# TO-DO: Remove these constants after transition of LTS to 24/7 availability
OPERATING_ZONE = 'Eastern Time (US & Canada)'
OPERATING_HOURS = {
start: 6,
end: 22,
saturday_end: 19
}.freeze

##
# @parameter [String] icn: icn of the Veteran requesting education benefits information
# @return [BenefitsEducation::Service] a new instance of the service
Expand Down Expand Up @@ -66,57 +58,5 @@ def handle_error(error, lighthouse_client_id, endpoint)
endpoint
)
end

##
# TO-DO: Remove this method after transition of LTS to 24/7 availability
#
# @return [Boolean] Is the current time within the system's scheduled uptime
#
def self.within_scheduled_uptime?
current_time = get_current_time
if current_time.saturday?
(OPERATING_HOURS[:start]...OPERATING_HOURS[:saturday_end]).cover?(current_time.hour)
else
(OPERATING_HOURS[:start]...OPERATING_HOURS[:end]).cover?(current_time.hour)
end
end

##
# TO-DO: Remove this method after transition of LTS to 24/7 availability
#
# @return [Integer] The number of seconds until scheduled system downtime begins
#
def self.seconds_until_downtime
if within_scheduled_uptime?
current_time = get_current_time
end_hour = current_time.saturday? ? OPERATING_HOURS[:saturday_end] : OPERATING_HOURS[:end]
tz = ActiveSupport::TimeZone.new(OPERATING_ZONE)
service_end_time = tz.parse("#{tz.today} #{end_hour}:00:00")
service_end_time - current_time
else
0
end
end

##
# TO-DO: Remove this method after transition of LTS to 24/7 availability
#
# @return [String] Next earliest date and time that the service will be available
#
def self.retry_after_time
current_time = get_current_time
tz = ActiveSupport::TimeZone.new(OPERATING_ZONE)
service_start_time = tz.parse("#{tz.today} 0#{OPERATING_HOURS[:start]}:00:00")

return service_start_time.httpdate if current_time.hour < OPERATING_HOURS[:start]

service_start_time.tomorrow.httpdate
end

def self.get_current_time
Time.now.in_time_zone(OPERATING_ZONE)
end

private_class_method :get_current_time
end
end
39 changes: 1 addition & 38 deletions postman/vets-api.pm-collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,43 +145,6 @@
},
"response": []
},
{
"name": "/v0/backend_statuses/{service}",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Endpoint returns valid backend status object\", function () {",
" if (pm.response.code != 200) { return };",
" var responseBody = pm.response.json();",
" pm.expect(responseBody).to.have.property('data');",
"});",
""
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{vets_api_env}}//v0/backend_statuses/gibs",
"host": [
"{{vets_api_env}}"
],
"path": [
"",
"v0",
"backend_statuses",
"gibs"
]
}
},
"response": []
},
{
"name": "/v0/forms",
"event": [
Expand Down Expand Up @@ -1175,4 +1138,4 @@
"type": "string"
}
]
}
}
Loading

0 comments on commit 879216f

Please sign in to comment.