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
4 changes: 1 addition & 3 deletions app/jobs/reports/monthly_key_metrics_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,7 @@ def total_user_count_report
end

def active_users_count_report
@active_users_count_report ||= Reporting::ActiveUsersCountReport.new(
report_date,
)
@active_users_count_report ||= Reporting::ActiveUsersCountReport.new(report_date)
end

def agency_and_sp_report
Expand Down
14 changes: 14 additions & 0 deletions app/services/reporting/active_users_count_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def generate_apg_report

[
['Active Users (APG)', 'IAL1', 'IDV', 'Total', 'Range start', 'Range end'],
monthly_active_users_apg.as_csv(title: 'Current month'),
q1.as_csv(title: 'Fiscal year Q1'),
q2.as_csv(title: 'Fiscal year Q2 cumulative'),
q3.as_csv(title: 'Fiscal year Q3 cumulative'),
Expand All @@ -94,6 +95,19 @@ def monthly_active_users
end
end

# @return [ReportRow]
def monthly_active_users_apg
@monthly_active_users_apg ||= Reports::BaseReport.transaction_with_timeout do
ReportRow.from_hash_time_range(
time_range: monthly_range,
hash: Db::Identity::SpActiveUserCounts.overall_apg(
monthly_range.begin,
monthly_range.end,
).first,
)
end
end

# @return [Array<ReportRow>]
def fiscal_year_active_users_per_quarter_cumulative
@fiscal_year_active_users_per_quarter_cumulative ||= begin
Expand Down
3 changes: 2 additions & 1 deletion spec/services/reporting/active_users_count_report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@

expected_table = [
['Active Users (APG)', 'IAL1', 'IDV', 'Total', 'Range start', 'Range end'],
['Current month', 0, 0, 0, Date.new(2023, 3, 1), Date.new(2023, 3, 31)],
['Fiscal year Q1', 0, 0, 0, Date.new(2022, 10, 1), Date.new(2022, 12, 31)],
['Fiscal year Q2 cumulative', 2, 0, 2, Date.new(2022, 10, 1), Date.new(2023, 3, 31)],
['Fiscal year Q3 cumulative', 2, 0, 2, Date.new(2022, 10, 1), Date.new(2023, 3, 31)],
Expand All @@ -106,7 +107,7 @@

emailable_report = report.active_users_count_apg_emailable_report

expect(Db::Identity::SpActiveUserCounts).to have_received(:overall_apg).exactly(2).times
expect(Db::Identity::SpActiveUserCounts).to have_received(:overall_apg).exactly(3).times

aggregate_failures do
emailable_report.table.zip(expected_table).each do |actual, expected|
Expand Down
Loading