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
6 changes: 3 additions & 3 deletions app/services/reporting/total_user_count_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ def total_user_count

def verified_user_count
Reports::BaseReport.transaction_with_timeout do
Profile.where(active: true).where('activated_at <= ?', end_date).count
Profile.where(active: true).where('verified_at <= ?', end_date).count
end
end

def new_verified_user_count
Reports::BaseReport.transaction_with_timeout do
Profile.where(active: true).where(activated_at: current_month).count
Profile.where(active: true).where(verified_at: current_month).count
end
end

Expand All @@ -79,7 +79,7 @@ def annual_total_user_count
def annual_verified_user_count
Reports::BaseReport.transaction_with_timeout do
Profile.where(active: true).
where(activated_at: annual_start_date..annual_end_date).
where(verified_at: annual_start_date..annual_end_date).
count
end
end
Expand Down
16 changes: 12 additions & 4 deletions lib/reporting/proofing_rate_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,20 @@ def to_csv
def reports
@reports ||= begin
sub_reports = [0, *DATE_INTERVALS].each_cons(2).map do |slice_end, slice_start|
time_range = if slice_end.zero?
Range.new(
(end_date - slice_start.days).beginning_of_day,
(end_date - slice_end.days).end_of_day,
)
else
Range.new(
(end_date - slice_start.days).beginning_of_day,
(end_date - slice_end.days).end_of_day - 1.day,
)
end
Reporting::IdentityVerificationReport.new(
issuers: nil, # all issuers
time_range: Range.new(
(end_date - slice_start.days).beginning_of_day,
(end_date - slice_end.days).beginning_of_day,
),
time_range: time_range,
cloudwatch_client: cloudwatch_client,
)
end
Expand Down
20 changes: 10 additions & 10 deletions spec/lib/reporting/proofing_rate_report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'reporting/proofing_rate_report'

RSpec.describe Reporting::ProofingRateReport do
let(:end_date) { Date.new(2022, 1, 1).in_time_zone('UTC').beginning_of_day }
let(:end_date) { Date.new(2022, 1, 1).in_time_zone('UTC').end_of_day }
let(:parallel) { true }

subject(:report) do
Expand All @@ -25,7 +25,7 @@
successfully_verified_users: 1,
idv_doc_auth_rejected: 1,
idv_fraud_rejected: 0,
time_range: (end_date - 30.days)..end_date,
time_range: (end_date - 30.days).beginning_of_day..end_date,
),
instance_double(
'Reporting::IdentityVerificationReport',
Expand All @@ -39,7 +39,7 @@
successfully_verified_users: 2,
idv_doc_auth_rejected: 1,
idv_fraud_rejected: 1,
time_range: (end_date - 60.days)..end_date,
time_range: (end_date - 60.days).beginning_of_day..end_date,
),
instance_double(
'Reporting::IdentityVerificationReport',
Expand All @@ -53,7 +53,7 @@
successfully_verified_users: 3,
idv_doc_auth_rejected: 1,
idv_fraud_rejected: 2,
time_range: (end_date - 90.days)..end_date,
time_range: (end_date - 90.days).beginning_of_day..end_date,
),
],
)
Expand Down Expand Up @@ -136,26 +136,26 @@

expect(report.reports.map(&:time_range)).to eq(
[
(end_date - 30.days)..end_date,
(end_date - 60.days)..end_date,
(end_date - 90.days)..end_date,
(end_date - 30.days).beginning_of_day..end_date,
(end_date - 60.days).beginning_of_day..end_date,
(end_date - 90.days).beginning_of_day..end_date,
],
)

expect(Reporting::IdentityVerificationReport).to have_received(:new).with(
time_range: (end_date - 30.days)..end_date,
time_range: (end_date - 30.days).beginning_of_day..end_date,
issuers: nil,
cloudwatch_client: report.cloudwatch_client,
).once

expect(Reporting::IdentityVerificationReport).to have_received(:new).with(
time_range: (end_date - 60.days)..(end_date - 30.days),
time_range: (end_date - 60.days).beginning_of_day..(end_date - 30.days).end_of_day,
issuers: nil,
cloudwatch_client: report.cloudwatch_client,
).once

expect(Reporting::IdentityVerificationReport).to have_received(:new).with(
time_range: (end_date - 90.days)..(end_date - 60.days),
time_range: (end_date - 90.days).beginning_of_day..(end_date - 60.days).end_of_day,
issuers: nil,
cloudwatch_client: report.cloudwatch_client,
).once
Expand Down
7 changes: 5 additions & 2 deletions spec/services/reporting/total_user_count_report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,13 @@

context 'with one verified and one non-verified user' do
before do
create(:user)
user1 = create(:user)
user2 = create(:user)
create(:profile, :active, :verified, user: user1)
# MW: The :verified trait doesn't set active: true. This feels confusing.
create(:profile, :active, user: user2)
# user2 active profile but unverified
create(:profile, :active, :verified, user: user2)
user2.profiles.first.deactivate(:password_reset)
end
let(:expected_total_count) { 2 }
let(:expected_verified_count) { 1 }
Expand Down