From 031dcabc3a254a093b1c265a8c05a324359521ee Mon Sep 17 00:00:00 2001 From: Luis Date: Fri, 22 Dec 2023 15:26:34 -0600 Subject: [PATCH 1/3] LG-11929 Update Daily Report Recipients changelog: Internal, Reporting, Streamline MKMR email config usage --- .../reports/monthly_key_metrics_report.rb | 5 +- config/application.yml.default | 10 ++-- lib/identity_config.rb | 5 +- .../monthly_key_metrics_report_spec.rb | 49 ++++++++++++++----- 4 files changed, 45 insertions(+), 24 deletions(-) diff --git a/app/jobs/reports/monthly_key_metrics_report.rb b/app/jobs/reports/monthly_key_metrics_report.rb index 683820b46ea..e472f3f7f0c 100644 --- a/app/jobs/reports/monthly_key_metrics_report.rb +++ b/app/jobs/reports/monthly_key_metrics_report.rb @@ -75,10 +75,9 @@ def reports end def emails - emails = [IdentityConfig.store.team_agnes_email] + emails = [*IdentityConfig.store.team_daily_reports_emails] if report_date.next_day.day == 1 - emails << IdentityConfig.store.team_all_feds_email - emails << IdentityConfig.store.team_all_contractors_email + emails += IdentityConfig.store.team_all_login_emails end emails end diff --git a/config/application.yml.default b/config/application.yml.default index 77078627be0..2b95f814b07 100644 --- a/config/application.yml.default +++ b/config/application.yml.default @@ -316,9 +316,8 @@ otp_min_attempts_remaining_warning_count: 3 system_demand_report_email: 'foo@bar.com' sp_issuer_user_counts_report_configs: '[]' team_ada_email: '' -team_agnes_email: '' -team_all_contractors_email: '' -team_all_feds_email: '' +team_all_login_emails: '[]' +team_daily_reports_emails: '[]' team_ursula_email: '' test_ssn_allowed_list: '' totp_code_interval: 30 @@ -578,9 +577,8 @@ test: skip_encryption_allowed_list: '[]' state_tracking_enabled: true team_ada_email: 'ada@example.com' - team_agnes_email: 'a@example.com' - team_all_contractors_email: 'c@example.com' - team_all_feds_email: 'f@example.com' + team_all_login_emails: '[b@example.com, c@example.com]' + team_daily_reports_emails: '[a@example.com, d@example.com]' telephony_adapter: test test_ssn_allowed_list: '999999999' totp_code_interval: 3 diff --git a/lib/identity_config.rb b/lib/identity_config.rb index af91e7b05c5..2883310fd36 100644 --- a/lib/identity_config.rb +++ b/lib/identity_config.rb @@ -453,9 +453,8 @@ def self.build_store(config_map) config.add(:state_tracking_enabled, type: :boolean) config.add(:system_demand_report_email, type: :string) config.add(:team_ada_email, type: :string) - config.add(:team_agnes_email, type: :string) - config.add(:team_all_contractors_email, type: :string) - config.add(:team_all_feds_email, type: :string) + config.add(:team_all_login_emails, type: :string) + config.add(:team_daily_reports_emails, type: :string) config.add(:team_ursula_email, type: :string) config.add(:telephony_adapter, type: :string) config.add(:test_ssn_allowed_list, type: :comma_separated_string_list) diff --git a/spec/jobs/reports/monthly_key_metrics_report_spec.rb b/spec/jobs/reports/monthly_key_metrics_report_spec.rb index c3ab446953e..cad5b0ea09b 100644 --- a/spec/jobs/reports/monthly_key_metrics_report_spec.rb +++ b/spec/jobs/reports/monthly_key_metrics_report_spec.rb @@ -30,17 +30,19 @@ } end - let(:mock_proofing_report_data) do - [ - ['metric', 'num_users', 'percent'], - ] - end + let(:mock_all_login_emails) { ['mock_feds@example.com', 'mock_contractors@example.com'] } + let(:mock_daily_reports_emails) { ['mock_agnes@example.com', 'mock_daily@example.com'] } let(:mock_proofing_rate_data) do [ ['Metric', 'Trailing 30d', 'Trailing 60d', 'Trailing 90d'], ] end + let(:mock_proofing_report_data) do + [ + ['metric', 'num_users', 'percent'], + ] + end before do allow(Identity::Hostdata).to receive(:env).and_return('int') @@ -57,11 +59,16 @@ allow(report.proofing_rate_report).to receive(:as_csv). and_return(mock_proofing_rate_data) + + allow(IdentityConfig.store).to receive(:team_daily_reports_emails). + and_return(mock_daily_reports_emails) + allow(IdentityConfig.store).to receive(:team_all_login_emails). + and_return(mock_all_login_emails) end it 'sends out a report to just to team agnes' do expect(ReportMailer).to receive(:tables_report).once.with( - email: [IdentityConfig.store.team_agnes_email], + email: anything, subject: 'Monthly Key Metrics Report - 2021-03-02', reports: anything, message: report.preamble, @@ -76,11 +83,7 @@ it 'sends out a report to everybody' do expect(ReportMailer).to receive(:tables_report).once.with( - email: [ - IdentityConfig.store.team_agnes_email, - IdentityConfig.store.team_all_feds_email, - IdentityConfig.store.team_all_contractors_email, - ], + email: anything, subject: 'Monthly Key Metrics Report - 2021-02-28', reports: anything, message: report.preamble, @@ -92,7 +95,7 @@ end it 'does not send out a report with no emails' do - allow(IdentityConfig.store).to receive(:team_agnes_email).and_return('') + allow(IdentityConfig.store).to receive(:team_daily_reports_emails).and_return('') expect(report).to_not receive(:reports) @@ -112,6 +115,28 @@ report.perform(report_date) end + describe '#emails' do + context 'on the first of the month' do + let(:report_date) { Date.new(2021, 3, 1).prev_day } + + it 'emails the whole login team' do + expected_array = mock_daily_reports_emails + expected_array += mock_all_login_emails + + expect(report.emails).to match_array(expected_array) + end + end + + context 'during the rest of the month' do + let(:report_date) { Date.new(2021, 3, 2).prev_day } + it 'only emails team_daily_reports' do + expect(report.emails).to match_array( + mock_daily_reports_emails, + ) + end + end + end + describe '#preamble' do let(:env) { 'prod' } subject(:preamble) { report.preamble(env:) } From 7489aa04d017a33baf8176b084e56e4cff1b2e17 Mon Sep 17 00:00:00 2001 From: Luis Date: Fri, 29 Dec 2023 10:06:45 -0600 Subject: [PATCH 2/3] PR comments --- lib/identity_config.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/identity_config.rb b/lib/identity_config.rb index 2883310fd36..3fcba955fdb 100644 --- a/lib/identity_config.rb +++ b/lib/identity_config.rb @@ -453,8 +453,8 @@ def self.build_store(config_map) config.add(:state_tracking_enabled, type: :boolean) config.add(:system_demand_report_email, type: :string) config.add(:team_ada_email, type: :string) - config.add(:team_all_login_emails, type: :string) - config.add(:team_daily_reports_emails, type: :string) + config.add(:team_all_login_emails, type: :json) + config.add(:team_daily_reports_emails, type: :json) config.add(:team_ursula_email, type: :string) config.add(:telephony_adapter, type: :string) config.add(:test_ssn_allowed_list, type: :comma_separated_string_list) From 29540fa83d6266d3687f1139483ca375f18a1eab Mon Sep 17 00:00:00 2001 From: Luis Date: Fri, 29 Dec 2023 10:49:06 -0600 Subject: [PATCH 3/3] Build fix --- config/application.yml.default | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/application.yml.default b/config/application.yml.default index 2b95f814b07..282ef4895d8 100644 --- a/config/application.yml.default +++ b/config/application.yml.default @@ -577,8 +577,8 @@ test: skip_encryption_allowed_list: '[]' state_tracking_enabled: true team_ada_email: 'ada@example.com' - team_all_login_emails: '[b@example.com, c@example.com]' - team_daily_reports_emails: '[a@example.com, d@example.com]' + team_all_login_emails: '["b@example.com", "c@example.com"]' + team_daily_reports_emails: '["a@example.com", "d@example.com"]' telephony_adapter: test test_ssn_allowed_list: '999999999' totp_code_interval: 3