Skip to content

Commit

Permalink
[API-43666] 526 v2 - Multiple alerts per transaction id (#20671)
Browse files Browse the repository at this point in the history
* select hourly unique claims on transaction id

* make test more specific

* move select up
  • Loading branch information
tycol7 authored Feb 11, 2025
1 parent 98aaab6 commit e9b4f61
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def unique_errors_by_transaction_id
status: 'errored', cid: '0oagdm49ygCSJTp8X297')

last_hour = ClaimsApi::AutoEstablishedClaim
.select('DISTINCT ON(transaction_id) *')
.where(created_at: 1.hour.ago..Time.zone.now,
status: 'errored', cid: '0oagdm49ygCSJTp8X297')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,20 @@
subject.perform
end

context 'when a va gov claim with the same transaction id errs in the same hour' do
before do
create(:auto_established_claim_va_gov, :errored, created_at: Time.zone.now, transaction_id: 'transaction_1')
create(:auto_established_claim_va_gov, :errored, created_at: 59.minutes.ago, transaction_id: 'transaction_1')
allow_any_instance_of(ClaimsApi::ReportHourlyUnsuccessfulSubmissions).to receive(:notify).and_return(nil)
end

it 'only alerts on one of the claims' do
subject.perform

expect(subject.instance_variable_get(:@va_gov_errored_claims)).to have_attributes(length: 1)
end
end

it 'does not alert for claims with specific errors' do
allow_any_instance_of(Flipper).to receive(:enabled?).with(:claims_hourly_slack_error_report_enabled)
.and_return(true)
Expand Down

0 comments on commit e9b4f61

Please sign in to comment.