Skip to content

Commit

Permalink
[Rated Disabilities] Update discrepancy logging to include more fine-…
Browse files Browse the repository at this point in the history
…grained data (#16198)

* Updating the discrepancy logging to include more fine-grained data
  • Loading branch information
jerekshoe authored Apr 4, 2024
1 parent b732041 commit ab2836b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
19 changes: 10 additions & 9 deletions app/controllers/v0/rated_disabilities_discrepancies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,26 @@ def show
lh_response = get_lh_rated_disabilities
evss_response = get_evss_rated_disabilities

lh_response_length = lh_response.dig('data', 'attributes', 'individual_ratings').length
evss_response_length = evss_response.rated_disabilities.length

if lh_response_length != evss_response_length
log_length_discrepancy((lh_response_length - evss_response_length).abs)
end
lh_ratings = lh_response.dig('data', 'attributes', 'individual_ratings')
evss_ratings = evss_response.rated_disabilities
log_length_discrepancy(evss_ratings, lh_ratings) if lh_ratings.length != evss_ratings.length

# This doesn't need to return anything at the moment
render json: nil
end

private

def log_length_discrepancy(difference)
message = "Discrepancy of #{difference} disability ratings"
def log_length_discrepancy(evss_ratings, lh_ratings)
message = 'Discrepancy between Lighthouse and EVSS disability ratings'

::Rails.logger.info(message, {
message_type: 'lh.rated_disabilities.length_discrepancy',
revision: 4
evss_length: evss_ratings.length,
evss_rating_ids: evss_ratings.pluck('rated_disability_id'),
lighthouse_length: lh_ratings.length,
lighthouse_rating_ids: lh_ratings.pluck('disability_rating_id'),
revision: 5
})
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,15 @@
# Lighthouse should return 3 items, but filter out the inactive one, so when comparing
# with EVSS (which should return 1 rating), there should be a discrepancy of 1 ratings
expect(Rails.logger).to have_received(:info).with(
'Discrepancy of 1 disability ratings',
{ message_type: 'lh.rated_disabilities.length_discrepancy', revision: 4 }
'Discrepancy between Lighthouse and EVSS disability ratings',
{
message_type: 'lh.rated_disabilities.length_discrepancy',
evss_length: 1,
evss_rating_ids: ['1'],
lighthouse_length: 2,
lighthouse_rating_ids: %w[1 2],
revision: 5
}
)
end

Expand All @@ -57,8 +64,15 @@
# so when comparing with EVSS (which should return 1 rating), there should be
# a discrepancy of 2 ratings
expect(Rails.logger).to have_received(:info).with(
'Discrepancy of 2 disability ratings',
{ message_type: 'lh.rated_disabilities.length_discrepancy', revision: 4 }
'Discrepancy between Lighthouse and EVSS disability ratings',
{
message_type: 'lh.rated_disabilities.length_discrepancy',
evss_length: 1,
evss_rating_ids: ['1'],
lighthouse_length: 3,
lighthouse_rating_ids: %w[1 3 5],
revision: 5
}
)
end
end
Expand Down

0 comments on commit ab2836b

Please sign in to comment.