Skip to content

Commit

Permalink
Add totals to ITF and EWS tables
Browse files Browse the repository at this point in the history
  • Loading branch information
tycol7 committed Sep 5, 2024
1 parent 6c0e439 commit 473f3ac
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def perform
@to,
consumer_claims_totals: monthly_claims_totals,
poa_totals: monthly_poa_totals,
itf_totals:,
ews_totals:
itf_totals: monthly_itf_totals,
ews_totals: monthly_ews_totals
).deliver_now
end

Expand Down Expand Up @@ -65,11 +65,31 @@ def monthly_claims_totals
def monthly_poa_totals
monthly_poa_consumers = ClaimsApi::PowerOfAttorney.where(created_at: @from..@to)

monthly_poa_by_cid_by_status = monthly_poa_consumers.group_by(&:cid).transform_values do |poas|
poas.group_by(&:status).transform_values(&:count)
monthly_poa_by_cid_by_status = monthly_poa_consumers.group_by(&:cid).transform_values do |poa|
poa.group_by(&:status).transform_values(&:count)
end

get_monthly_summary_by_consumer_by_status(monthly_poa_by_cid_by_status)
end

def monthly_itf_totals
monthly_itf_consumers = ClaimsApi::IntentToFile.where(created_at: @from..@to)

monthly_itf_by_cid_by_status = monthly_itf_consumers.group_by(&:cid).transform_values do |itf|
itf.group_by(&:status).transform_values(&:count)
end

get_monthly_summary_by_consumer_by_status(monthly_itf_by_cid_by_status)
end

def monthly_ews_totals
monthly_ews_consumers = ClaimsApi::EvidenceWaiverSubmission.where(created_at: @from..@to)

monthly_ews_by_cid_by_status = monthly_ews_consumers.group_by(&:cid).transform_values do |ews|
ews.group_by(&:status).transform_values(&:count)
end

get_monthly_summary_by_consumer_by_status(monthly_ews_by_cid_by_status)
end
end
end
34 changes: 32 additions & 2 deletions modules/claims_api/spec/sidekiq/report_monthly_submissions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
[]
end,
poa_totals: defined?(expected_poa_totals) ? match_array(expected_poa_totals) : [],
ews_totals: [],
itf_totals: []
itf_totals: defined?(expected_itf_totals) ? match_array(expected_itf_totals) : [],
ews_totals: defined?(expected_ews_totals) ? match_array(expected_ews_totals) : []
).and_return(double.tap do |mailer|
expect(mailer).to receive(:deliver_now).once
end)
Expand Down Expand Up @@ -132,6 +132,36 @@ def setup_three_poas
it_behaves_like 'sends mail with expected totals'
end

context 'three ITFs' do
let(:claim_setup) { :setup_three_itfs }
let(:expected_itf_totals) do
[{ 'VA TurboClaim' => { submitted: 1, errored: 1, totals: 2 } },
{ 'VA.gov' => { submitted: 1, totals: 1 } },
{ 'Totals' => { submitted: 2, errored: 1, totals: 3 } }]
end

def setup_three_itfs
create(:intent_to_file, cid: '0oa9uf05lgXYk6ZXn297')
create(:intent_to_file, status: 'errored', cid: '0oa9uf05lgXYk6ZXn297')
create(:intent_to_file, cid: '0oagdm49ygCSJTp8X297')
end
end

context 'three EWSs' do
let(:claim_setup) { :setup_three_ews }
let(:expected_ews_totals) do
[{ 'VA TurboClaim' => { submitted: 1, errored: 1, totals: 2 } },
{ 'VA.gov' => { submitted: 1, totals: 1 } },
{ 'Totals' => { submitted: 2, errored: 1, totals: 3 } }]
end

def setup_three_ews
create(:evidence_waiver_submission, cid: '0oa9uf05lgXYk6ZXn297')
create(:evidence_waiver_submission, status: 'errored', cid: '0oa9uf05lgXYk6ZXn297')
create(:evidence_waiver_submission, cid: '0oagdm49ygCSJTp8X297')
end
end

context 'shared reporting behavior' do
it_behaves_like 'shared reporting behavior'
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def unsuccessful_poa_submissions
def ews_totals
[
{ 'consumer 1' => { totals: 10, updated: 5, errored: 2, pending: 1, uploaded: 2 } },
{ 'consumer 2' => { totals: 8, updated: 3, errored: 2, pending: 1, uploaded: 2 } }
{ 'consumer 2' => { totals: 8, updated: 3, errored: 2, pending: 1, uploaded: 2 } },
{ 'Totals' => { totals: 18, updated: 8, errored: 4, pending: 2, uploaded: 4 } }
]
end

Expand All @@ -61,7 +62,8 @@ def unsuccessful_evidence_waiver_submissions
def itf_totals
[
{ 'consumer 1' => { totals: 2, submitted: 1, errored: 1 } },
{ 'consumer 2' => { totals: 1, submitted: 1, errored: 0 } }
{ 'consumer 2' => { totals: 1, submitted: 1, errored: 0 } },
{ 'Totals' => { totals: 3, submitted: 2, errored: 1 } }
]
end
end

0 comments on commit 473f3ac

Please sign in to comment.