diff --git a/app/jobs/reports/api_transaction_count_report.rb b/app/jobs/reports/api_transaction_count_report.rb index 1de086e745f..a3a67534450 100644 --- a/app/jobs/reports/api_transaction_count_report.rb +++ b/app/jobs/reports/api_transaction_count_report.rb @@ -28,7 +28,6 @@ def perform(date = Time.zone.yesterday.end_of_day) end ReportMailer.tables_report( - title: 'API Transaction Count Report', email: email_addresses, subject: "API Transaction Count Report - #{report_date.to_date}", reports: reports, diff --git a/lib/reporting/api_transaction_count_report.rb b/lib/reporting/api_transaction_count_report.rb index 42a0f78c602..8fa2a6db196 100644 --- a/lib/reporting/api_transaction_count_report.rb +++ b/lib/reporting/api_transaction_count_report.rb @@ -30,7 +30,6 @@ def as_tables def as_emailable_reports [ Reporting::EmailableReport.new( - title: 'API Transaction Count Report', subtitle: '', float_as_percent: true, precision: 2, @@ -119,12 +118,12 @@ def fraud_score_and_attribute_table def fetch_results(query:) Rails.logger.info("Executing query: #{query}") - Rails.logger.info("Time range: #{time_range.begin.to_date} to #{time_range.end.to_date}") + Rails.logger.info("Time range: #{time_range.begin.to_time} to #{time_range.end.to_time}") results = cloudwatch_client.fetch( query:, - from: time_range.begin.to_date, - to: time_range.end.to_date, + from: time_range.begin.to_time, + to: time_range.end.to_time, ) Rails.logger.info("Results: #{results.inspect}") diff --git a/spec/lib/reporting/api_transaction_count_report_spec.rb b/spec/lib/reporting/api_transaction_count_report_spec.rb index 3a22282206f..1e3f342678e 100644 --- a/spec/lib/reporting/api_transaction_count_report_spec.rb +++ b/spec/lib/reporting/api_transaction_count_report_spec.rb @@ -14,15 +14,21 @@ let(:expected_api_transaction_count_table) do [ ['Week', 'True ID', 'Instant verify', 'Phone Finder', 'Socure (DocV)', - 'Fraud Score and Attribute', 'Instant Verify', 'Threat Metrix'], - ["#{time_range.begin.to_date} - #{time_range.end.to_date}", 10, 15, 20, 25, 30, 35, 40, 45], + 'Fraud Score and Attribute', 'Threat Metrix'], + ["#{time_range.begin.to_date} - #{time_range.end.to_date}", 10, 15, 20, 25, 30, 40], ] end - subject(:report) { Reporting::ApiTransactionCountReport.new(time_range:) } + subject(:report) { described_class.new(time_range:) } before do allow_any_instance_of(Reporting::CloudwatchClient).to receive(:fetch).and_return(mock_results) + allow(report).to receive(:true_id_table).and_return([10, mock_results]) + allow(report).to receive(:instant_verify_table).and_return([15, mock_results]) + allow(report).to receive(:phone_finder_table).and_return([20, mock_results]) + allow(report).to receive(:socure_table).and_return([25, mock_results]) + allow(report).to receive(:fraud_score_and_attribute_table).and_return([30, mock_results]) + allow(report).to receive(:threat_metrix_table).and_return([40, mock_results]) end describe '#api_transaction_count' do @@ -35,9 +41,12 @@ header_row = table.first data_row = table.last - expect(header_row).to include('Week', 'True ID', 'Instant verify', 'Phone Finder') + expect(header_row).to eq( + ['Week', 'True ID', 'Instant verify', 'Phone Finder', 'Socure (DocV)', + 'Fraud Score and Attribute', 'Threat Metrix'], + ) expect(data_row.first).to eq("#{time_range.begin.to_date} - #{time_range.end.to_date}") - expect(data_row[1..].all? { |val| val.is_a?(Integer) || val.is_a?(Array) }).to be true + expect(data_row[1..]).to eq([10, 15, 20, 25, 30, 40]) end end @@ -49,7 +58,13 @@ expect(csvs.size).to eq(1) csv = csvs.first - expect(csv).to include('Week,True ID,Instant verify') + expect(csv).to match( + / + Week,True\ ID,Instant\ verify,Phone\ Finder, # Match the first part + Socure\ \(DocV\),Fraud\ Score\ and\ Attribute, # Match the second part + Threat\ Metrix # Match the last part + /x, + ) expect(csv).to include("#{time_range.begin.to_date} - #{time_range.end.to_date}") end end @@ -58,8 +73,10 @@ it 'returns a valid emailable report object' do reports = report.as_emailable_reports + expect(reports).to be_an(Array) expect(reports.first).to be_a(Reporting::EmailableReport) - expect(reports.first.title).to eq('API Transaction Count Report') + expect(reports.first.filename).to eq('api_transaction_count_report') + expect(reports.first.table).to eq(report.api_transaction_count) end end end