Skip to content

Commit

Permalink
Merge branch 'master' into mm/1422-v1
Browse files Browse the repository at this point in the history
  • Loading branch information
MarchandMD authored Nov 18, 2024
2 parents c8b6246 + 3a4e8d7 commit e91a126
Show file tree
Hide file tree
Showing 33 changed files with 1,404 additions and 1,878 deletions.
1 change: 0 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ app/controllers/v1/decision_review_evidences_controller.rb @department-of-vetera
app/controllers/v1/decision_review_notification_callbacks_controller.rb @department-of-veterans-affairs/benefits-decision-reviews-be @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/controllers/v1/apidocs_controller.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/controllers/v1/notice_of_disagreements_controller.rb @department-of-veterans-affairs/benefits-decision-reviews-be @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/controllers/v1/pension_ipf_callbacks_controller.rb @department-of-veterans-affairs/pension-and-burials @department-of-veterans-affairs/backend-review-group
app/controllers/v1/sessions_controller.rb @department-of-veterans-affairs/octo-identity
app/controllers/v1/supplemental_claims_controller.rb @department-of-veterans-affairs/benefits-decision-reviews-be @department-of-veterans-affairs/backend-review-group
app/controllers/v1/supplemental_claims @department-of-veterans-affairs/benefits-decision-reviews-be @department-of-veterans-affairs/backend-review-group
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/be_review_prs.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
name: Require backend-review-group approval
on:
pull_request:
types: [opened, reopened, review_requested, synchronize, ready_for_review]
pull_request_review:
types: [submitted]

Expand Down
6 changes: 6 additions & 0 deletions app/controllers/v0/health_care_applications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ class HealthCareApplicationsController < ApplicationController
before_action(only: :rating_info) { authorize(:hca_disability_rating, :access?) }

def rating_info
if Flipper.enabled?(:hca_disable_bgs_service)
# Return 0 when not calling the actual BGS::Service
render json: HCARatingInfoSerializer.new({ user_percent_of_disability: 0 })
return
end

service = BGS::Service.new(current_user)
disability_rating = service.find_rating_data[:disability_rating_record][:service_connected_combined_degree]

Expand Down
79 changes: 0 additions & 79 deletions app/controllers/v1/pension_ipf_callbacks_controller.rb

This file was deleted.

25 changes: 14 additions & 11 deletions app/controllers/v1/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ def authenticate
def user_login(saml_response)
user_session_form = UserSessionForm.new(saml_response)
raise_saml_error(user_session_form) unless user_session_form.valid?
mhv_unverified_validation(user_session_form)

mhv_unverified_validation(user_session_form.user)
create_user_verification(user_session_form.user)
@current_user, @session_object = user_session_form.persist
set_cookies
after_login_actions
Expand All @@ -158,8 +158,18 @@ def user_login(saml_response)
login_stats(:success)
end

def mhv_unverified_validation(user_session_form)
if html_escaped_relay_state['type'] == 'mhv_verified' && user_session_form.user.loa[:current] < LOA::THREE
def create_user_verification(user)
user_verifier_object = OpenStruct.new({ sign_in: user.identity.sign_in,
mhv_correlation_id: user.mhv_correlation_id,
idme_uuid: user.idme_uuid,
edipi: user.identity.edipi,
logingov_uuid: user.logingov_uuid,
icn: user.icn })
Login::UserVerifier.new(user_verifier_object).perform
end

def mhv_unverified_validation(user)
if html_escaped_relay_state['type'] == 'mhv_verified' && user.loa[:current] < LOA::THREE
mhv_unverified_error = SAML::UserAttributeError::ERRORS[:mhv_unverified_blocked]
Rails.logger.warn("SessionsController version:v1 #{mhv_unverified_error[:message]}")
raise SAML::UserAttributeError.new(message: mhv_unverified_error[:message],
Expand Down Expand Up @@ -398,13 +408,6 @@ def set_cookies
end

def after_login_actions
user_verifier_object = OpenStruct.new({ sign_in: @current_user.identity.sign_in,
mhv_correlation_id: @current_user.mhv_correlation_id,
idme_uuid: @current_user.idme_uuid,
edipi: @current_user.identity.edipi,
logingov_uuid: @current_user.logingov_uuid,
icn: @current_user.icn })
Login::UserVerifier.new(user_verifier_object).perform
Login::AfterLoginActions.new(@current_user).perform
log_persisted_session_and_warnings
end
Expand Down
20 changes: 0 additions & 20 deletions app/models/pension_ipf_notification.rb

This file was deleted.

4 changes: 2 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ def needs_accepted_terms_of_use
end

def user_verification
@user_verification ||= get_user_verification
@user_verification ||= UserVerification.find_by(id: user_verification_id)
end

def user_account
@user_account ||= user_verification&.user_account
end

def user_verification_id
@user_verification_id ||= user_verification&.id
@user_verification_id ||= get_user_verification&.id
end

def user_account_uuid
Expand Down
42 changes: 18 additions & 24 deletions app/sidekiq/benefits_intake_status_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,27 @@ def initialize(batch_size: BATCH_SIZE)

def perform
Rails.logger.info('BenefitsIntakeStatusJob started')
form_submissions_and_attempts = FormSubmission.joins(:form_submission_attempts)
resolved_form_submission_ids = form_submissions_and_attempts
.where(form_submission_attempts: { aasm_state: %w[vbms failure] })
.pluck(:id)
pending_form_submissions = form_submissions_and_attempts
.where(form_submission_attempts: { aasm_state: 'pending' })
.where.not(id: resolved_form_submission_ids)
# We're calculating the resolved_form_submissions and removing them because it is possible for a FormSubmission
# to have two (or more) attempts, one 'pending' and the other 'vbms'. In such cases we don't want to include
# that FormSubmission because it has been resolved.
total_handled, result = batch_process(pending_form_submissions)
pending_form_submission_attempts = FormSubmissionAttempt.where(aasm_state: 'pending')
total_handled, result = batch_process(pending_form_submission_attempts)
Rails.logger.info('BenefitsIntakeStatusJob ended', total_handled:) if result
end

private

def batch_process(pending_form_submissions)
def batch_process(pending_form_submission_attempts)
total_handled = 0
intake_service = BenefitsIntake::Service.new

pending_form_submissions.each_slice(batch_size) do |batch|
batch_uuids = batch.map { |submission| submission.latest_attempt&.benefits_intake_uuid }
pending_form_submission_attempts.each_slice(batch_size) do |batch|
batch_uuids = batch.map(&:benefits_intake_uuid)
response = intake_service.bulk_status(uuids: batch_uuids)

# Log the entire response for debugging purposes
Rails.logger.info("Received bulk status response: #{response.body}")

raise response.body unless response.success?

total_handled += handle_response(response, batch)
total_handled += handle_response(response)
end

[total_handled, true]
Expand All @@ -67,7 +58,7 @@ def batch_process(pending_form_submissions)
end

# rubocop:disable Metrics/MethodLength
def handle_response(response, pending_form_submissions)
def handle_response(response)
total_handled = 0

# Ensure response body contains data, and log the data for debugging
Expand All @@ -78,13 +69,10 @@ def handle_response(response, pending_form_submissions)

response.body['data']&.each do |submission|
uuid = submission['id']
form_submission = pending_form_submissions.find do |submission_from_db|
submission_from_db.latest_attempt&.benefits_intake_uuid == uuid
end
form_id = form_submission.form_type
saved_claim_id = form_submission.saved_claim_id

form_submission_attempt = form_submission.latest_pending_attempt
form_submission_attempt = form_submission_attempts_hash[uuid]
form_submission = form_submission_attempt&.form_submission
form_id = form_submission&.form_type
saved_claim_id = form_submission&.saved_claim_id
time_to_transition = (Time.zone.now - form_submission_attempt.created_at).truncate

# https://developer.va.gov/explore/api/benefits-intake/docs
Expand Down Expand Up @@ -197,12 +185,18 @@ def monitor_failure(form_id, saved_claim_id, bi_uuid)
if %w[28-1900].include?(form_id)
claim = SavedClaim::VeteranReadinessEmploymentClaim.find(saved_claim_id)
if claim
claim.submit_failure_email
claim.send_failure_email
VRE::Monitor.new.log_silent_failure_avoided(context, nil, call_location:)
else
VRE::Monitor.new.log_silent_failure(context, nil, call_location:)
end
end
end
# rubocop:enable Metrics/MethodLength

def form_submission_attempts_hash
@_form_submission_attempts_hash ||= FormSubmissionAttempt
.where(aasm_state: 'pending')
.index_by(&:benefits_intake_uuid)
end
end
27 changes: 27 additions & 0 deletions app/sidekiq/form1010cg/submission_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
module Form1010cg
class SubmissionJob
STATSD_KEY_PREFIX = "#{Form1010cg::Auditor::STATSD_KEY_PREFIX}.async.".freeze
DD_ZSF_TAGS = [
'caregiver-application',
'function: 10-10CG async form submission'
].freeze
include Sidekiq::Job
include Sidekiq::MonitoredWorker
include SentryLogging
Expand All @@ -15,6 +19,12 @@ class SubmissionJob

sidekiq_retries_exhausted do |msg, _e|
StatsD.increment("#{STATSD_KEY_PREFIX}failed_no_retries_left", tags: ["claim_id:#{msg['args'][0]}"])
StatsD.increment('silent_failure_avoided_no_confirmation', tags: DD_ZSF_TAGS)

if Flipper.enabled?(:caregiver_use_va_notify_on_submission_failure)
claim = SavedClaim::CaregiversAssistanceClaim.find(msg['args'][0])
send_failure_email(claim.parsed_form) if claim.parsed_form.dig('veteran', 'email')
end
end

def retry_limits_for_notification
Expand Down Expand Up @@ -47,5 +57,22 @@ def perform(claim_id)

raise
end

def self.send_failure_email(parsed_form)
first_name = parsed_form.dig('veteran', 'fullName', 'first')
email = parsed_form.dig('veteran', 'email')
template_id = Settings.vanotify.services.health_apps_1010.template_id.form1010_cg_failure_email
api_key = Settings.vanotify.services.health_apps_1010.api_key
salutation = first_name ? "Dear #{first_name}," : ''

VANotify::EmailJob.perform_async(
email,
template_id,
{ 'salutation' => salutation },
api_key
)

StatsD.increment("#{STATSD_KEY_PREFIX}submission_failure_email_sent")
end
end
end
15 changes: 10 additions & 5 deletions config/features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,16 @@ features:
caregiver1010:
actor_type: user
description: Enables new features while investigating 1010CG errors
caregiver_use_va_notify_on_submission_failure:
actor_type: user
description: Send 10-10CG submission failure email to Veteran using VANotify.
enable_in_development: true
hca_browser_monitoring_enabled:
actor_type: user
description: Enables browser monitoring for the health care application.
hca_disable_bgs_service:
actor_type: user
description: Do not call the BGS Service when this is turned on. Instead return 0 for rating.
hca_enrollment_status_override_enabled:
actor_type: user
description: Enables override of enrollment status for a user, to allow multiple submissions with same user.
Expand Down Expand Up @@ -1151,6 +1158,9 @@ features:
my_va_form_submission_statuses:
actor_type: user
description: Enables users to view the status of submitted forms.
my_va_form_submission_pdf_link:
actor_type: user
description: Enables users to view PDF link within submitted forms cards
rated_disabilities_detect_discrepancies:
actor_type: user
description:
Expand Down Expand Up @@ -1690,10 +1700,6 @@ features:
actor_type: user
description: Supplemental Claim new form updates
enable_in_development: true
pension_ipf_callbacks_endpoint:
actor_type: user
description: Pension IPF VANotify notification callbacks endpoint
enable_in_development: true
hlr_browser_monitoring_enabled:
actor_type: user
description: HLR Datadog RUM monitoring
Expand Down Expand Up @@ -1871,4 +1877,3 @@ features:
is_DGIB_endpoint:
actor_type: user
description: used to call data from DGIB endpoints for MGIB VYE application

1 change: 0 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,6 @@

scope format: false do
resources :nod_callbacks, only: [:create], controller: :decision_review_notification_callbacks
resources :pension_ipf_callbacks, only: [:create]
end
end

Expand Down
4 changes: 1 addition & 3 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1399,6 +1399,7 @@ vanotify:
health_apps_1010:
api_key: fake_secret
template_id:
form1010_cg_failure_email: fake_template_id
form1010_ez_failure_email: fake_template_id
form1010_ezr_failure_email: fake_template_id
# https://support.atlassian.com/bitbucket-cloud/docs/yaml-anchors/
Expand Down Expand Up @@ -1792,9 +1793,6 @@ brd:
nod_vanotify_status_callback:
bearer_token: bearer_token_secret

pension_ipf_vanotify_status_callback:
bearer_token: bearer_token_secret

travel_pay:
sts:
service_account_id: ~
Expand Down
Loading

0 comments on commit e91a126

Please sign in to comment.