-
Notifications
You must be signed in to change notification settings - Fork 167
LG-9956 sp count with issuer param #8596
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 15 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
a9957a3
initial commit wiht all necessary files
nprimak 9bf4aed
put the config argument in the wrong place
nprimak 0c0479d
fix rubocop errors
nprimak f6d0c84
Merge branch 'main' into np/LG-9956/sp_count_with_issuer_param
nprimak 4b05947
remove newlines
nprimak 950a384
refactor and remove json parsing
nprimak c723ada
improve the sql
nprimak 085bfc9
refactor to resemble the deleted accounts report more
nprimak 64906c5
Update app/jobs/reports/sp_issuer_user_counts_report.rb
nprimak 10cd23e
test - still in progress
nprimak 3c70e1c
fix sql query and update tests
nprimak a6c34fb
rubocop autocorrect
nprimak 05447b7
Merge branch 'main' into np/LG-9956/sp_count_with_issuer_param
nprimak c8756ac
Add changelog
nprimak a00a530
normalize_yaml
nprimak 92b6b80
Update spec/jobs/reports/sp_issuer_user_counts_report_spec.rb
nprimak bcc934c
Update app/mailers/report_mailer.rb
nprimak 4f1fead
Update app/jobs/reports/sp_issuer_user_counts_report.rb
nprimak 5f78c82
remove team_ursula_email from config
nprimak 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,30 @@ | ||
| require 'identity/hostdata' | ||
| require 'json' | ||
|
|
||
| module Reports | ||
| class SpIssuerUserCountsReport < BaseReport | ||
| REPORT_NAME = 'sp-issuer-user-counts-report'.freeze | ||
|
|
||
| def perform(_date) | ||
| configs = IdentityConfig.store.sp_issuer_user_counts_report_configs | ||
|
|
||
| configs.each do |report_hash| | ||
| emails = report_hash['emails'] | ||
| issuer = report_hash['issuer'] | ||
|
|
||
| user_counts = Db::Identity::SpUserCounts.with_issuer(issuer) | ||
|
|
||
| emails.each do |email| | ||
| ReportMailer.sp_issuer_user_counts_report( | ||
| name: REPORT_NAME, | ||
| email: email, | ||
| issuer: issuer, | ||
| total: user_counts['total'], | ||
| ial1_total: user_counts['ial1_total'], | ||
| ial2_total: user_counts['ial2_total'], | ||
| ).deliver_now | ||
| end | ||
| end | ||
| 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
5 changes: 5 additions & 0 deletions
5
app/views/report_mailer/sp_issuer_user_counts_report.html.erb
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,5 @@ | ||
| <%= t('report_mailer.sp_issuer_user_counts_report.name') %>: <%= @name %><br> | ||
| <%= t('report_mailer.sp_issuer_user_counts_report.issuer') %>: <%= @issuer %><br> | ||
| <%= t('report_mailer.sp_issuer_user_counts_report.total') %>: <%= @total %><br> | ||
| <%= t('report_mailer.sp_issuer_user_counts_report.ial1_total') %>: <%= @ial1_total %><br> | ||
| <%= t('report_mailer.sp_issuer_user_counts_report.ial2_total') %>: <%= @ial2_total %><br> |
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,33 @@ | ||
| require 'rails_helper' | ||
|
|
||
| RSpec.describe Reports::SpIssuerUserCountsReport do | ||
| let(:name) { 'sp-issuer-user-counts-report' } | ||
| let(:issuer) { 'urn:gov:gsa:openidconnect:sp:sinatra' } | ||
| let(:email) { 'foo@bar.com' } | ||
| let(:user) { create(:user) } | ||
| let(:uuid) { 'foo' } | ||
| let(:last_authenticated_at) { '2020-01-02 12:03:04 UTC' } | ||
|
|
||
| subject { described_class.new } | ||
|
|
||
| it 'sends out a report to the email listed with one total user' do | ||
| create( | ||
| :service_provider_identity, | ||
| service_provider: issuer, | ||
| user: user, | ||
| uuid: uuid, | ||
| last_authenticated_at: last_authenticated_at, | ||
| ) | ||
|
|
||
| allow(IdentityConfig.store).to receive(:sp_issuer_user_counts_report_configs).and_return( | ||
| [{ 'issuer' => issuer, 'emails' => [email] }], | ||
| ) | ||
| allow(ReportMailer).to receive(:sp_issuer_user_counts_report).and_call_original | ||
|
|
||
| expect(ReportMailer).to receive(:sp_issuer_user_counts_report).with( | ||
| name: name, email: email, ial1_total: 1, ial2_total: 0, issuer: issuer, total: 1, | ||
| ) | ||
|
nprimak marked this conversation as resolved.
Outdated
|
||
|
|
||
| subject.perform(Time.zone.today) | ||
| end | ||
| end | ||
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.