-
Notifications
You must be signed in to change notification settings - Fork 167
LG-6668 safeguard failed message #6647
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
9359303
LG-6668 safeguard failed message
peggles2 bd1c7e0
remove extra space
peggles2 6224bfa
fix lint errors
peggles2 de52d6e
Add changelog
peggles2 c15256e
simplified the alert hash in the test
peggles2 2ee0694
changes made to comma delimit the alert values
peggles2 9a9ef13
remove has_failed
peggles2 e5938f3
update code to just log when written over
peggles2 ff6575a
fix linter errors
peggles2 860077a
Add changelog
peggles2 de25f66
add a comment to service class method
peggles2 1517f52
update lint errors
peggles2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
app/services/doc_auth/processed_alert_to_log_alert_formatter.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| module DocAuth | ||
| class ProcessedAlertToLogAlertFormatter | ||
| def get_alert_result(log_alert_results, side, alert_name_key, result) | ||
| if log_alert_results.dig(alert_name_key, side.to_sym).present? | ||
| alert_value = log_alert_results[alert_name_key][side.to_sym] | ||
| Rails.logger. | ||
| info("ALERT ALREADY HAS A VALUE: #{alert_value}, #{result}") | ||
| end | ||
| result | ||
| end | ||
|
|
||
| def log_alerts(alerts) | ||
| log_alert_results = {} | ||
|
|
||
| alerts.keys.each do |key| | ||
| alerts[key.to_sym].each do |alert| | ||
| alert_name_key = alert[:name]. | ||
| downcase. | ||
| parameterize(separator: '_').to_sym | ||
| side = alert[:side] || 'no_side' | ||
|
|
||
| log_alert_results[alert_name_key] = | ||
| { "#{side}": get_alert_result( | ||
| log_alert_results, | ||
| side, | ||
| alert_name_key, | ||
| alert[:result], | ||
| ) } | ||
| end | ||
| end | ||
| log_alert_results | ||
| end | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
spec/services/doc_auth/processed_alert_to_log_alert_formatter_spec.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # Take the proccessed alerts and reformat them in a hash so that its easier to search and collect | ||
| # stats through cloudwatch. | ||
|
|
||
| require 'rails_helper' | ||
|
|
||
| RSpec.describe DocAuth::ProcessedAlertToLogAlertFormatter do | ||
| let(:alerts) do | ||
| { passed: [{ alert: 'Alert_1', name: 'Visible Pattern', result: 'Passed' }], | ||
| failed: | ||
| [ | ||
| { alert: 'Alert_1', name: '2D Barcode Read', result: 'Failed' }, | ||
| { alert: 'Alert_2', name: 'Layout Valid', result: 'Attention' }, | ||
| { alert: 'Alert_3', name: '2D Barcode Read', result: 'Failed' }, | ||
| { alert: 'Alert_4', name: 'Visible Pattern', result: 'Failed' }, | ||
| { alert: 'Alert_5', name: 'Visible Photo Characteristics', result: 'Failed' }, | ||
| ] } | ||
| end | ||
|
|
||
| context('when ProcessedAlertToLogAlertFormatter is called') do | ||
| subject { | ||
| DocAuth::ProcessedAlertToLogAlertFormatter.new.log_alerts(alerts) | ||
| } | ||
|
|
||
| it('returns failed if both passed and failed are returned by the alert') do | ||
| expect(subject).to match(a_hash_including(visible_pattern: { no_side: 'Failed' })) | ||
| end | ||
|
|
||
| it('returns the formatted log hash') do | ||
| expect(subject).to eq( | ||
| { '2d_barcode_read': { no_side: 'Failed' }, | ||
| layout_valid: { no_side: 'Attention' }, | ||
| visible_pattern: { no_side: 'Failed' }, | ||
| visible_photo_characteristics: { no_side: 'Failed' } }, | ||
| ) | ||
| end | ||
| end | ||
| end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.