Class: V0::RatedDisabilitiesDiscrepanciesController
- Inherits:
-
ApplicationController
- Object
- ActionController::API
- ApplicationController
- V0::RatedDisabilitiesDiscrepanciesController
- Defined in:
- app/controllers/v0/rated_disabilities_discrepancies_controller.rb
Constant Summary collapse
- DECISION_ALLOWLIST =
['1151 Denied', '1151 Granted', 'Not Service Connected', 'Service Connected'].freeze
Constants inherited from ApplicationController
ApplicationController::VERSION_STATUS
Constants included from SignIn::Authentication
SignIn::Authentication::BEARER_PATTERN
Constants included from ExceptionHandling
ExceptionHandling::SKIP_SENTRY_EXCEPTION_TYPES
Instance Attribute Summary
Attributes inherited from ApplicationController
Instance Method Summary collapse
- #active?(rating) ⇒ Boolean private
-
#evss_service ⇒ Object
private
EVSS.
- #filter_ratings_by_decision!(ratings) ⇒ Object private
- #get_auth_headers ⇒ Object private
- #get_evss_rated_disabilities ⇒ Object private
-
#get_lh_rated_disabilities ⇒ Object
private
Lighthouse.
- #log_length_discrepancy(evss_ratings, lh_ratings) ⇒ Object private
- #reject_inactive_ratings!(ratings) ⇒ Object private
- #service ⇒ Object private
- #show ⇒ Object
Methods inherited from ApplicationController
#clear_saved_form, #cors_preflight, #pagination_params, #render_job_id, #routing_error, #set_csrf_header
Methods included from Traceable
Methods included from SentryControllerLogging
#set_tags_and_extra_context, #tags_context, #user_context
Methods included from SentryLogging
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger, #set_sentry_metadata
Methods included from Instrumentation
Methods included from SignIn::Authentication
#access_token, #access_token_authenticate, #authenticate, #authenticate_access_token, #bearer_token, #cookie_access_token, #handle_authenticate_error, #load_user, #load_user_object, #scrub_bearer_token, #validate_request_ip
Methods included from Headers
Methods included from ExceptionHandling
#render_errors, #report_mapped_exception, #report_original_exception, #skip_sentry_exception?, #skip_sentry_exception_types
Methods included from AuthenticationAndSSOConcerns
#authenticate, #clear_session, #extend_session!, #load_user, #log_sso_info, #render_unauthorized, #reset_session, #set_api_cookie!, #set_current_user, #set_session_expiration_header, #set_session_object, #sign_in_service_exp_time, #sign_in_service_session, #sso_cookie_content, #sso_logging_info, #validate_inbound_login_params, #validate_session
Methods included from SignIn::AudienceValidator
#authenticate, #validate_audience!
Instance Method Details
#active?(rating) ⇒ Boolean (private)
76 77 78 79 80 81 82 |
# File 'app/controllers/v0/rated_disabilities_discrepancies_controller.rb', line 76 def active?() date = ['rating_end_date'] # In order for the rating to be considered active, # the date should be either nil or in the future date.nil? || Date.parse(date).future? end |
#evss_service ⇒ Object (private)
EVSS
42 43 44 45 |
# File 'app/controllers/v0/rated_disabilities_discrepancies_controller.rb', line 42 def evss_service auth_headers = get_auth_headers @evss_service ||= EVSS::DisabilityCompensationForm::Service.new(auth_headers) end |
#filter_ratings_by_decision!(ratings) ⇒ Object (private)
68 69 70 |
# File 'app/controllers/v0/rated_disabilities_discrepancies_controller.rb', line 68 def () .select! { || DECISION_ALLOWLIST.include?(['decision']) } end |
#get_auth_headers ⇒ Object (private)
47 48 49 |
# File 'app/controllers/v0/rated_disabilities_discrepancies_controller.rb', line 47 def get_auth_headers EVSS::AuthHeaders.new(@current_user).to_h end |
#get_evss_rated_disabilities ⇒ Object (private)
51 52 53 |
# File 'app/controllers/v0/rated_disabilities_discrepancies_controller.rb', line 51 def get_evss_rated_disabilities evss_service.get_rated_disabilities end |
#get_lh_rated_disabilities ⇒ Object (private)
Lighthouse
56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/controllers/v0/rated_disabilities_discrepancies_controller.rb', line 56 def get_lh_rated_disabilities response = service.get_rated_disabilities(@current_user.icn) # We only want active ratings if response.dig('data', 'attributes', 'individual_ratings') (response['data']['attributes']['individual_ratings']) (response['data']['attributes']['individual_ratings']) end response end |
#log_length_discrepancy(evss_ratings, lh_ratings) ⇒ Object (private)
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/v0/rated_disabilities_discrepancies_controller.rb', line 28 def log_length_discrepancy(, ) = 'Discrepancy between Lighthouse and EVSS disability ratings' ::Rails.logger.info(, { message_type: 'lh.rated_disabilities.length_discrepancy', evss_length: .length, evss_rating_ids: .pluck('rated_disability_id'), lighthouse_length: .length, lighthouse_rating_ids: .pluck('disability_rating_id'), revision: 5 }) end |
#reject_inactive_ratings!(ratings) ⇒ Object (private)
72 73 74 |
# File 'app/controllers/v0/rated_disabilities_discrepancies_controller.rb', line 72 def () .select! { || active?() } end |
#service ⇒ Object (private)
84 85 86 |
# File 'app/controllers/v0/rated_disabilities_discrepancies_controller.rb', line 84 def service @service ||= VeteranVerification::Service.new end |
#show ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/v0/rated_disabilities_discrepancies_controller.rb', line 14 def show lh_response = get_lh_rated_disabilities evss_response = get_evss_rated_disabilities = lh_response.dig('data', 'attributes', 'individual_ratings') = evss_response.rated_disabilities log_length_discrepancy(, ) if .length != .length # This doesn't need to return anything at the moment render json: nil end |