Skip to content
Merged
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
46 changes: 34 additions & 12 deletions lib/reporting/api_transaction_count_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def initialize(
time_range:,
verbose: false,
progress: false,
slice: 6.hours,
threads: 1
slice: 1.day,
threads: 5
)
@time_range = time_range
@verbose = verbose
Expand Down Expand Up @@ -76,18 +76,20 @@ def api_transaction_count
'Socure (KYC) - Shadow',
'Socure (KYC) - Non-Shadow',
'Fraud Score and Attribute',
'Threat Metrix',
'Threat Metrix (IDV)',
'Threat Metrix (Auth Only)',
],
[
"#{ time_range.begin.to_date} - #{time_range.end.to_date}",
true_id_table.first,
instant_verify_table.first,
phone_finder_table.first,
socure_table.first,
socure_kyc_non_shadow_table.first,
socure_kyc_shadow_table.first,
socure_kyc_non_shadow_table.first,
fraud_score_and_attribute_table.first,
threat_metrix_table.first,
threat_metrix_idv_table.first,
threat_metrix_auth_only_table.first,
],
]
end
Expand Down Expand Up @@ -138,8 +140,14 @@ def instant_verify_table
[instant_verify_table_count, result]
end

def threat_metrix_table
result = fetch_results(query: threat_metrix_query)
def threat_metrix_idv_table
result = fetch_results(query: threat_metrix_idv_query)
threat_metrix_table_count = result.count
[threat_metrix_table_count, result]
end

def threat_metrix_auth_only_table
result = fetch_results(query: threat_metrix_auth_only_query)
threat_metrix_table_count = result.count
[threat_metrix_table_count, result]
end
Expand Down Expand Up @@ -200,6 +208,7 @@ def true_id_query
properties.event_properties.vendor as vendor
| display uuid, id, timestamp, sp, dol_state, success,
billed, vendor, product_status, transaction_status, conversation_id, request_id, referenceID, decision_status, submit_attempts, remaining_submit_attempts
| limit 10000
QUERY
end

Expand All @@ -221,6 +230,7 @@ def phone_finder_query
| display uuid, id, timestamp, sp, dol_state, success,
phoneFinder_referenceID, phoneFinder_transactionID, phoneFinder_pass,
coalesce(temp_checks,"passed_all","") as phoneFinder_checks
| limit 10000
QUERY
end

Expand All @@ -236,6 +246,7 @@ def socure_query
properties.event_properties.reference_id as reference_id, properties.event_properties.submit_attempts as submit_attempts,
replace(replace(strcontains(name, "front"),"1","front"),"0","back") as side
| display uuid, id, timestamp, sp, dol_state, success, decision_result, side, docv_transaction_token, reference_id, submit_attempts
| limit 10000
QUERY
end

Expand Down Expand Up @@ -271,19 +282,29 @@ def instant_verify_query
resolution_transactionID,
resolution_success,
resolution_timed_out_flag
| limit 10000
QUERY
end

def threat_metrix_query
def threat_metrix_idv_query
<<~QUERY
filter name = "IdV: doc auth verify proofing results"
| fields
properties.user_id as uuid,
@timestamp as timestamp,
properties.event_properties.proofing_results.context.stages.threatmetrix.success as tmx_success

| stats max(tmx_success) as max_tmx_success by uuid

| limit 10000
QUERY
end

def threat_metrix_auth_only_query
<<~QUERY
filter name = "account_creation_tmx_result"
| fields
properties.user_id as uuid,
@timestamp as timestamp,
| limit 10000
QUERY
end

Expand All @@ -301,6 +322,7 @@ def fraud_score_and_attribute_query
properties.event_properties.response_body.fraudpoint.vulnerable_victim_index as vulnerable_victim_index,
properties.event_properties.response_body.fraudpoint.risk_indicators_codes as risk_indicators_codes,
properties.event_properties.response_body.fraudpoint.risk_indicators_descriptions as risk_indicators_descriptions
| limit 10000
QUERY
end

Expand All @@ -324,7 +346,7 @@ def socure_kyc_shadow_query
properties.event_properties.socure_result.errors.I919 as I919,
properties.event_properties.socure_result.errors.R354 as R354
| filter name = "idv_socure_shadow_mode_proofing_result"
| stats count(*) as c
| limit 10000
QUERY
end

Expand All @@ -334,7 +356,7 @@ def socure_kyc_non_shadow_query
| filter name='IdV: doc auth verify proofing results'
and properties.event_properties.proofing_results.context.stages.resolution.vendor_name='socure_kyc'
| sort @timestamp desc
| stats count(*) as c
| limit 10000
QUERY
end
end
Expand Down
18 changes: 5 additions & 13 deletions spec/lib/reporting/api_transaction_count_report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@
]
end

let(:expected_api_transaction_count_table) do
[
['Week', 'True ID', 'Instant verify', 'Phone Finder', 'Socure (DocV)',
'Socure (KYC) - Shadow', 'Socure (KYC) - Non-Shadow',
'Fraud Score and Attribute', 'Threat Metrix'],
["#{time_range.begin.to_date} - #{time_range.end.to_date}", 10, 15, 20, 25, 30, 35, 40],
]
end

subject(:report) { described_class.new(time_range:) }

before do
Expand All @@ -30,7 +21,8 @@
allow(report).to receive(:socure_kyc_non_shadow_table).and_return([30, mock_results])
allow(report).to receive(:socure_kyc_shadow_table).and_return([35, mock_results])
allow(report).to receive(:fraud_score_and_attribute_table).and_return([40, mock_results])
allow(report).to receive(:threat_metrix_table).and_return([45, mock_results])
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])
end

describe '#api_transaction_count' do
Expand All @@ -46,10 +38,10 @@
expect(header_row).to eq(
['Week', 'True ID', 'Instant verify', 'Phone Finder', 'Socure (DocV)',
'Socure (KYC) - Shadow', 'Socure (KYC) - Non-Shadow',
'Fraud Score and Attribute', 'Threat Metrix'],
'Fraud Score and Attribute', 'Threat Metrix (IDV)', 'Threat Metrix (Auth Only)'],
)
expect(data_row.first).to eq("#{time_range.begin.to_date} - #{time_range.end.to_date}")
expect(data_row[1..]).to eq([10, 15, 20, 25, 30, 35, 40, 45])
expect(data_row[1..]).to eq([10, 15, 20, 25, 35, 30, 40, 45, 50])
end
end

Expand All @@ -65,7 +57,7 @@
/
Week,True\ ID,Instant\ verify,Phone\ Finder,
Socure\ \(DocV\),Socure\ \(KYC\)\s-\sShadow,Socure\ \(KYC\)\s-\sNon-Shadow,
Fraud\ Score\ and\ Attribute,Threat\ Metrix
Fraud\ Score\ and\ Attribute,Threat\ Metrix\s\(IDV\),Threat\ Metrix\s\(Auth\ Only\)
/x,
)
expect(csv).to include("#{time_range.begin.to_date} - #{time_range.end.to_date}")
Expand Down