-
Notifications
You must be signed in to change notification settings - Fork 166
Lg 10912 email monthly report #9193
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
16 commits
Select commit
Hold shift + click to select a range
9a7da92
LG-10912 Reformat Account Reuse Report
ThatSpaceGuy 168866a
spec fix
ThatSpaceGuy b088625
LG-10912 Send Email of Key Metric report
ThatSpaceGuy 4f62c53
lint fixes
ThatSpaceGuy 0c6936f
PR Comments
ThatSpaceGuy ba7c8cb
PR Comments
ThatSpaceGuy fa5ec6c
Leverage the tables report
ThatSpaceGuy 23928c1
Integrate tables_report
ThatSpaceGuy b0e8449
Fixing report format
ThatSpaceGuy 83c961c
Fix table formatting (and a nit)
n1zyy 801586c
lintfix
n1zyy 2722c13
PR comment and build fix work
ThatSpaceGuy e857dc1
PR Comments
ThatSpaceGuy 87c33cf
PR comments and clean-up
ThatSpaceGuy a9f23d6
Fix formatting and add empty email check
ThatSpaceGuy 38af4ff
spec fix
ThatSpaceGuy 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
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,50 @@ | ||
| require 'csv' | ||
|
|
||
| module Reports | ||
| class MonthlyKeyMetricsReport < BaseReport | ||
| REPORT_NAME = 'monthly-key-metrics-report'.freeze | ||
|
|
||
| attr_reader :report_date | ||
|
|
||
| def perform(date) | ||
| @report_date = date | ||
| csv_for_email = monthly_key_metrics_report_array | ||
| email_message = "Report: #{REPORT_NAME} #{date}" | ||
| email_addresses = emails.select(&:present?) | ||
|
|
||
| if !email_addresses.empty? | ||
| ReportMailer.tables_report( | ||
| email: email_addresses, | ||
| subject: "Monthly Key Metrics Report - #{date}", | ||
| message: email_message, | ||
| tables: csv_for_email, | ||
| ).deliver_now | ||
| else | ||
| Rails.logger.warn 'No email addresses received - Monthly Key Metrics Report NOT SENT' | ||
| end | ||
| end | ||
|
|
||
| def emails | ||
| emails = [IdentityConfig.store.team_agnes_email] | ||
| if Identity::Hostdata.env == 'prod' && report_date.day == 1 | ||
| emails << IdentityConfig.store.team_all_feds_email | ||
| end | ||
| emails | ||
| end | ||
|
|
||
| def monthly_key_metrics_report_array | ||
| csv_array = [] | ||
|
|
||
| account_reuse_report_csv.each do |row| | ||
| csv_array << row | ||
| end | ||
|
|
||
| csv_array | ||
| end | ||
|
|
||
| # Individual Key Metric Report | ||
| def account_reuse_report_csv | ||
| Reports::MonthlyAccountReuseReport.new(report_date).report_csv | ||
| 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
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,55 @@ | ||
| require 'rails_helper' | ||
|
|
||
| RSpec.describe Reports::MonthlyKeyMetricsReport do | ||
| subject(:report) { Reports::MonthlyKeyMetricsReport.new } | ||
|
|
||
| let(:report_date) { Date.new(2021, 3, 2) } | ||
| let(:name) { 'monthly-key-metrics-report' } | ||
| let(:agnes_email) { 'fake@agnes_email.com' } | ||
| let(:feds_email) { 'fake@feds_email.com' } | ||
|
|
||
| before do | ||
| allow(IdentityConfig.store).to receive(:team_agnes_email). | ||
| and_return(agnes_email) | ||
| allow(IdentityConfig.store).to receive(:team_all_feds_email). | ||
| and_return(feds_email) | ||
| allow(Identity::Hostdata).to receive(:env).and_return('prod') | ||
| end | ||
|
|
||
| it 'sends out a report to the email listed with one total user' do | ||
| expect(ReportMailer).to receive(:tables_report).once.with( | ||
| message: 'Report: monthly-key-metrics-report 2021-03-02', | ||
| email: [agnes_email], | ||
| subject: 'Monthly Key Metrics Report - 2021-03-02', | ||
| tables: anything, | ||
| ).and_call_original | ||
|
|
||
| subject.perform(report_date) | ||
| end | ||
|
|
||
| it 'sends out a report to the emails listed with two users' do | ||
| first_of_month_date = report_date - 1 | ||
|
|
||
| expect(ReportMailer).to receive(:tables_report).once.with( | ||
| message: 'Report: monthly-key-metrics-report 2021-03-01', | ||
| email: [agnes_email, feds_email], | ||
| subject: 'Monthly Key Metrics Report - 2021-03-01', | ||
| tables: anything, | ||
| ).and_call_original | ||
|
|
||
| subject.perform(first_of_month_date) | ||
| end | ||
|
|
||
| it 'does not send out a report with no emails' do | ||
| allow(IdentityConfig.store).to receive(:team_agnes_email).and_return('') | ||
|
|
||
| expect(ReportMailer).not_to receive(:tables_report).with( | ||
| message: 'Report: monthly-key-metrics-report 2021-03-02', | ||
| email: [''], | ||
| subject: 'Monthly Key Metrics Report - 2021-03-02', | ||
| tables: anything, | ||
| ).and_call_original | ||
|
|
||
| subject.perform(report_date) | ||
| 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
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.