-
Notifications
You must be signed in to change notification settings - Fork 166
LG-10040 automate ial1 funnel report #9295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d5626d3
Add Reports::AuthenticationReport
Sgtpluck 92902d4
Add mailer
Sgtpluck 0b6bbed
Add job to run weekly report
Sgtpluck 3d2d059
changelog: User-Facing Improvements, Reporting, Adding automated week…
Sgtpluck 0c854e4
Using the reusable tables_report ReportMailer method
Sgtpluck 3736cb7
Add as_csv method to report in order to correctly return data in an a…
Sgtpluck 1a67793
Add newline after return statement
Sgtpluck 9164075
Add more realistic looking table
Sgtpluck dfa4d27
Update to make tables prettier
Sgtpluck 755e9ba
Update name
Sgtpluck c371179
Update lib/reporting/authentication_report.rb
Sgtpluck 688a701
Update tables to each be their own method
Sgtpluck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| require 'reporting/authentication_report' | ||
|
|
||
| module Reports | ||
| class AuthenticationReport < BaseReport | ||
| REPORT_NAME = 'authentication-report' | ||
|
|
||
| attr_accessor :report_date | ||
|
|
||
| def perform(report_date) | ||
| return unless IdentityConfig.store.s3_reports_enabled | ||
|
|
||
| self.report_date = report_date | ||
| message = "Report: #{REPORT_NAME} #{report_date}" | ||
| subject = "Weekly Authentication Report - #{report_date}" | ||
|
|
||
| report_configs.each do |report_hash| | ||
| tables = weekly_authentication_report_tables(report_hash['issuers']) | ||
|
|
||
| report_hash['emails'].each do |email| | ||
| ReportMailer.tables_report( | ||
| email:, | ||
| subject:, | ||
| message:, | ||
| tables:, | ||
| ).deliver_now | ||
| end | ||
| end | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def weekly_authentication_report_tables(issuers) | ||
| Reporting::AuthenticationReport.new( | ||
| issuers:, | ||
| time_range: report_date.all_week, | ||
| ).as_tables_with_options | ||
| end | ||
|
|
||
| def report_configs | ||
| IdentityConfig.store.weekly_auth_funnel_report_config | ||
| end | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| require 'rails_helper' | ||
|
|
||
| RSpec.describe Reports::AuthenticationReport do | ||
| let(:issuer) { 'issuer1' } | ||
| let(:issuers) { [issuer] } | ||
| let(:report_date) { Date.new(2023, 12, 25) } | ||
| let(:email) { 'partner.name@example.com' } | ||
| let(:name) { 'Partner Name' } | ||
|
|
||
| let(:report_configs) do | ||
| [ | ||
| { | ||
| 'name' => name, | ||
| 'issuers' => issuers, | ||
| 'emails' => [email], | ||
| }, | ||
| ] | ||
| end | ||
|
|
||
| before do | ||
| allow(IdentityConfig.store).to receive(:s3_reports_enabled).and_return(true) | ||
| allow(IdentityConfig.store).to receive(:weekly_auth_funnel_report_config) { report_configs } | ||
| end | ||
|
|
||
| describe '#perform' do | ||
| let(:tables) do | ||
| [ | ||
| [ | ||
| { title: 'Overview' }, | ||
| ['Report Timeframe', '2023-10-01 00:00:00 UTC to 2023-10-01 23:59:59 UTC'], | ||
| ['Report Generated', '2023-10-02'], | ||
| ['Issuer', 'some:issuer'], | ||
| ['Total # of IAL1 Users', '75'], | ||
| ], | ||
| [ | ||
| { title: 'Authentication Metrics Report' }, | ||
| ['Metric', 'Number of accounts', '% of total from start'], | ||
| ['New Users Started IAL1 Verification', '100', '100%'], | ||
| ['New Users Completed IAL1 Password Setup', '85', '85%'], | ||
| ['New Users Completed IAL1 MFA', '80', '80%'], | ||
| ['New IAL1 Users Consented to Partner', '75', '75%'], | ||
| ['AAL2 Authentication Requests from Partner', '12', '12%'], | ||
| ['AAL2 Authenticated Requests', '50', '50%'], | ||
| ], | ||
| ] | ||
| end | ||
|
|
||
| let(:weekly_report) { double(Reporting::AuthenticationReport, as_tables_with_options: tables) } | ||
|
|
||
| before do | ||
| expect(Reporting::AuthenticationReport).to receive(:new).with( | ||
| issuers:, | ||
| time_range: report_date.all_week, | ||
| ) { weekly_report } | ||
|
|
||
| allow(ReportMailer).to receive(:tables_report).and_call_original | ||
| end | ||
|
|
||
| it 'emails the csv' do | ||
| expect(ReportMailer).to receive(:tables_report).with( | ||
| email:, | ||
| subject: "Weekly Authentication Report - #{report_date}", | ||
| message: "Report: authentication-report #{report_date}", | ||
| tables:, | ||
| ) | ||
|
|
||
| subject.perform(report_date) | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.