Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 59 additions & 13 deletions lib/reporting/api_transaction_count_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ def api_transaction_count
'Threat Metrix (IDV)',
'Threat Metrix (Auth Only)',
'LN Emailage',
'GPO',
'AAMVA',
'Socure PhoneRisk (Shadow)',
],
[
"#{ time_range.begin.to_date} - #{time_range.end.to_date}",
Expand All @@ -94,6 +97,9 @@ def api_transaction_count
threat_metrix_idv_table.first,
threat_metrix_auth_only_table.first,
ln_emailage_table.first,
gpo_table.first,
aamva_table.first,
socure_phonerisk_table.first,
],
]
end
Expand All @@ -120,13 +126,6 @@ def true_id_selfie_table
[true_id_selfie_table_count, result]
end

# def true_id_selfie_table
# result = fetch_results(query: true_id_selfie_query)
# # Sum all the individual counts
# true_id_selfie_table_count = result.sum { |r| r['total_count'].to_i }
# [true_id_selfie_table_count, result]
# end

def phone_finder_table
result = fetch_results(query: phone_finder_query)
phone_finder_table_count = result.count
Expand Down Expand Up @@ -157,12 +156,6 @@ def ln_emailage_table
[ln_emailage_table_count, result]
end

# def ln_emailage_table
# result = fetch_results(query: ln_emailage_count_query)
# ln_emailage_table_count = result.sum { |r| r['total_count'].to_i }
# [ln_emailage_table_count, result]
# end

def instant_verify_table
result = fetch_results(query: instant_verify_query)
instant_verify_table_count = result.count
Expand All @@ -187,6 +180,24 @@ def fraud_score_and_attribute_table
[fraud_score_and_attribute_table_count, result]
end

def gpo_table
result = fetch_results(query: gpo_query)
gpo_table_count = result.count
[gpo_table_count, result]
end

def aamva_table
result = fetch_results(query: aamva_query)
aamva_table_count = result.count
[aamva_table_count, result]
end

def socure_phonerisk_table
result = fetch_results(query: socure_phonerisk_query)
socure_phonerisk_table_count = result.count
[socure_phonerisk_table_count, result]
end

def fetch_results(query:)
Rails.logger.info("Executing query: #{query}")
Rails.logger.info("Time range: #{time_range.begin.to_time} to #{time_range.end.to_time}")
Expand Down Expand Up @@ -384,6 +395,41 @@ def ln_emailage_query
| limit 10000
QUERY
end

def gpo_query
<<~QUERY
fields @timestamp, @message, @log, id
|filter name = 'gpo_confirmation_upload' #GPO confirmation records were uploaded for letter sends
| stats count(*) as gpo_transactions
| limit 10000
QUERY
end

def aamva_query
<<~QUERY
fields @timestamp, @message, @log, id
| filter name IN ['IdV: doc auth verify proofing results', ‘idv_state_id_validation’]
| fields jsonParse(@message) as message
| unnest message.properties.event_properties.proofing_results.context.stages.state_id into state_id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@koseni123 @shilenpatel1 for this, we should just need should_proof_state_id=true as the filter within this event property and something indicating that we got a response from AAMVA. success or failure at the event level doesnt matter.

| unnest message.properties.event_properties.proofing_results.context.should_proof_state_id into @should_proof_state_id
| fields state_id.vendor_name as @vendor_name, name,
coalesce(@vendor_name,properties.event_properties.vendor_name) as vendor_name ,
coalesce(@should_proof_state_id,0) as should_proof_state_id
| filter (name = 'IdV: doc auth verify proofing results' and should_proof_state_id = 1) or (name = 'idv_state_id_validation')
| filter vendor_name = 'aamva:state_id'
| stats count(*) as aamva_transactions_ipp
| limit 10000
QUERY
end

def socure_phonerisk_query
<<~QUERY
fields @timestamp, @message, @log, id
| filter name IN ["idv_socure_shadow_mode_phonerisk_result"]
| stats count(*) as socure_phonerisk_transactions
| limit 10000
QUERY
end
end
end

Expand Down
40 changes: 30 additions & 10 deletions spec/lib/reporting/api_transaction_count_report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
allow(report).to receive(:threat_metrix_idv_table).and_return([45, mock_results])
allow(report).to receive(:threat_metrix_auth_only_table).and_return([50, mock_results])
allow(report).to receive(:ln_emailage_table).and_return([60, mock_results])
allow(report).to receive(:gpo_table).and_return([70, mock_results])
allow(report).to receive(:aamva_table).and_return([80, mock_results])
allow(report).to receive(:socure_phonerisk_table).and_return([90, mock_results])
end

describe '#api_transaction_count' do
Expand All @@ -51,10 +54,14 @@
'Threat Metrix (IDV)',
'Threat Metrix (Auth Only)',
'LN Emailage',
'GPO',
'AAMVA',
'Socure PhoneRisk (Shadow)',
],
)

expect(data_row.first).to eq("#{time_range.begin.to_date} - #{time_range.end.to_date}")
expect(data_row[1..]).to eq([10, 11, 15, 20, 25, 26, 30, 40, 45, 50, 60])
expect(data_row[1..]).to eq([10, 11, 15, 20, 25, 26, 30, 40, 45, 50, 60, 70, 80, 90])
end
end

Expand All @@ -66,16 +73,29 @@
expect(csvs.size).to eq(1)

csv = csvs.first
expect(csv).to match(
/
Week,True\ ID,True\ ID\ \(Selfie\),Instant\ verify,Phone\ Finder,
Socure\ \(DocV\),Socure\ \(DocV\ -\ Selfie\),
Socure\ \(KYC\),
Fraud\ Score\ and\ Attribute,Threat\ Metrix\s\(IDV\),
Threat\ Metrix\s\(Auth\ Only\),LN\ Emailage
/x,
)

# Check for all column headers in the CSV
expected_headers = [
'Week',
'True ID',
'True ID (Selfie)',
'Instant verify',
'Phone Finder',
'Socure (DocV)',
'Socure (DocV - Selfie)',
'Socure (KYC)',
'Fraud Score and Attribute',
'Threat Metrix (IDV)',
'Threat Metrix (Auth Only)',
'LN Emailage',
'GPO',
'AAMVA',
'Socure PhoneRisk (Shadow)',
].join(',')

expect(csv).to include(expected_headers)
expect(csv).to include("#{time_range.begin.to_date} - #{time_range.end.to_date}")
expect(csv).to include('10,11,15,20,25,26,30,40,45,50,60,70,80,90')
end
end

Expand Down