Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/bundler/debug-1.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-mcneil authored Dec 20, 2024
2 parents 5cd9b57 + 69d29cc commit a6edf36
Show file tree
Hide file tree
Showing 28 changed files with 2,094 additions and 2,512 deletions.
27 changes: 18 additions & 9 deletions app/models/health_care_application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ class HealthCareApplication < ApplicationRecord
FORM_ID = '10-10EZ'
ACTIVEDUTY_ELIGIBILITY = 'TRICARE'
DISABILITY_THRESHOLD = 50
DD_ZSF_TAGS = [
'service:healthcare-application',
'function: 10-10EZ async form submission'
].freeze
LOCKBOX = Lockbox.new(key: Settings.lockbox.master_key, encode: true)

attr_accessor :user, :async_compatible, :google_analytics_client_id, :form
Expand Down Expand Up @@ -255,15 +259,14 @@ def log_sync_submission_failure
end

def log_async_submission_failure
log_zero_silent_failures
log_zero_silent_failures unless Flipper.enabled?(:hca_zero_silent_failures)
StatsD.increment("#{HCA::Service::STATSD_KEY_PREFIX}.failed_wont_retry")
StatsD.increment("#{HCA::Service::STATSD_KEY_PREFIX}.failed_wont_retry_short_form") if short_form?
log_submission_failure_details
end

def log_zero_silent_failures
tags = ['service:healthcare-application', 'function: 10-10EZ async form submission']
StatsD.increment('silent_failure_avoided_no_confirmation', tags:)
StatsD.increment('silent_failure_avoided_no_confirmation', tags: DD_ZSF_TAGS)
end

def log_submission_failure_details
Expand Down Expand Up @@ -292,13 +295,19 @@ def send_failure_email
api_key = Settings.vanotify.services.health_apps_1010.api_key

salutation = first_name ? "Dear #{first_name}," : ''
metadata =
{
callback_metadata: {
notification_type: 'error',
form_number: FORM_ID,
statsd_tags: DD_ZSF_TAGS
}
}

VANotify::EmailJob.perform_async(
email,
template_id,
{ 'salutation' => salutation },
api_key
)
params = [email, template_id, { 'salutation' => salutation }, api_key]
params << metadata if Flipper.enabled?(:hca_zero_silent_failures)

VANotify::EmailJob.perform_async(*params)
StatsD.increment("#{HCA::Service::STATSD_KEY_PREFIX}.submission_failure_email_sent")
rescue => e
log_exception_to_sentry(e)
Expand Down
3 changes: 3 additions & 0 deletions config/features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ features:
hca_retrieve_facilities_without_repopulating:
actor_type: user
description: Constrain facilities endpoint to only return existing facilities values - even if the table is empty, do not rerun the Job to populate it.
hca_zero_silent_failures:
actor_type: user
description: Pass callback metadata to vanotify sidekiq job
cg1010_oauth_2_enabled:
actor_type: user
description: Use OAuth 2.0 Authentication for 10-10CG Form Mulesoft integration.
Expand Down
3 changes: 3 additions & 0 deletions lib/periodic_jobs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
# Update Optionset data cache
mgr.register('0 0 * * *', 'Crm::OptionsetDataJob')

# Update Facilities data cache
mgr.register('0 0 * * *', 'Crm::FacilitiesDataJob')

# Update FormSubmissionAttempt status from Lighthouse Benefits Intake API
mgr.register('0 0 * * *', 'BenefitsIntakeStatusJob')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,20 @@ def search
api_result.tmp_covid_online_scheduling = mobile_api_get_by_id(api_result.id)
end
end
render_json(serializer, lighthouse_params, api_results)

patsr_approved_codes = retrieve_patsr_approved_facilities.pluck(:FacilityCode)

filtered_results = WillPaginate::Collection.create(
api_results.current_page,
api_results.per_page,
api_results.total_entries
) do |pager|
filtered_items = api_results.select { |object| patsr_approved_codes.include?(object.unique_id) }
pager.replace(filtered_items)
pager.total_entries = filtered_items.size
end

render_json(serializer, lighthouse_params, filtered_results)
end

def show
Expand All @@ -28,6 +41,11 @@ def show

private

def retrieve_patsr_approved_facilities
data = Crm::CacheData.new.fetch_and_cache_data(endpoint: 'Facilities', cache_key: 'Facilities', payload: {})
JSON.parse(data, symbolize_names: true)[:Data]
end

def api
FacilitiesApi::V2::Lighthouse::Client.new
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ def call
inquiry_details = base_inquiry_details(inquiry_params[:your_role])

if education_benefits?(inquiry_params[:select_category],
inquiry_params[:select_topic])
inquiry_params[:select_topic]) ||
inquiry_params[:who_is_your_question_about] == "It's a general question"
return general_inquiry(inquiry_params, inquiry_details)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def fetch_state(state_code)
def formatted_pronouns(pronouns)
return unless pronouns

pronouns[:pronouns_not_listed_text].presence || pronouns.key(true)&.to_s&.tr('_', '/')
pronouns[:pronouns_not_listed_text].presence || pronouns.key('true')&.to_s&.tr('_', '/')
end

def contact_field(field, inquiry_details, inquiry_params)
Expand Down
28 changes: 28 additions & 0 deletions modules/ask_va_api/app/sidekiq/crm/facilities_data_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# frozen_string_literal: true

require 'sidekiq'

module Crm
class FacilitiesDataJob
include Sidekiq::Job

# Schedule to run every 24 hours. Adjust as needed.
sidekiq_options retry: false, unique_for: 24.hours

def perform
Crm::CacheData.new.fetch_and_cache_data(endpoint: 'Facilities', cache_key: 'Facilities', payload: {})
rescue => e
log_error('optionset', e)
end

private

def log_error(action, exception)
LogService.new.call(action) do |span|
span.set_tag('error', true)
span.set_tag('error.msg', exception.message)
end
Rails.logger.error("Error during #{action}: #{exception.message}")
end
end
end
Loading

0 comments on commit a6edf36

Please sign in to comment.