-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Retry getting a rating profile on BGS::ShareError #15316
Changes from all commits
3300965
5d1fe2d
e253de3
a7f8783
a6ca483
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,10 @@ def ratings_from_bgs_response(response) | |
|
||
attr_writer :rating_profile | ||
|
||
def rating_profile | ||
@rating_profile ||= fetch_rating_profile | ||
end | ||
|
||
private | ||
|
||
def fetch_rating_profile | ||
|
@@ -65,9 +69,24 @@ def fetch_rating_profile | |
) | ||
rescue Savon::Error | ||
{} | ||
rescue BGS::ShareError | ||
retry_fetching_rating_profile | ||
end | ||
|
||
def rating_profile | ||
@rating_profile ||= fetch_rating_profile | ||
# Re-tries fetching the rating profile with the RatingAtIssue service | ||
def retry_fetching_rating_profile | ||
ratings_at_issue = RatingAtIssue.fetch_in_range( | ||
participant_id: participant_id, | ||
start_date: profile_date, | ||
end_date: profile_date | ||
Comment on lines
+80
to
+81
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should the start and end dates be the same? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, with the regular service we can fetch a specific rating profile using the veteran's participant ID and profile date. With the "back" service, we can fetch a range by date instead of a specific one. So this limits the results, and then another (just in case) matching is done using the profile date comparison method which includes the timestamp. |
||
) | ||
matching_rating = ratings_at_issue.find { |rating| profile_date_matches(rating.profile_date) } | ||
matching_rating.present? ? matching_rating.rating_profile : {} | ||
end | ||
|
||
# The profile date is used as a key when fetching a rating by profile date. | ||
# Profile dates in RatingAtIssue appear to have the same Date/Time stamp, but sometimes disagree by one timezone | ||
def profile_date_matches(profile_date_to_compare) | ||
profile_date.strftime("%Y-%m-%d %H:%M:%S") == profile_date_to_compare.strftime("%Y-%m-%d %H:%M:%S") | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to rescue the generic ShareError instead of the specific one originally listed in the AC because I figure anytime we get the ShareError, it's worth trying the other service as a backup.