-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11288 from 18F/stages/rc-2024-09-26
Deploy RC 417 to Production
- Loading branch information
Showing
26 changed files
with
763 additions
and
175 deletions.
There are no files selected for viewing
This file contains 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 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 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
74 changes: 74 additions & 0 deletions
74
app/jobs/reports/idv_legacy_conversion_supplement_report.rb
This file contains 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,74 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'csv' | ||
|
||
module Reports | ||
class IdvLegacyConversionSupplementReport < BaseReport | ||
REPORT_NAME = 'idv-legacy-conversion-supplement-report' | ||
|
||
def perform(_date) | ||
csv = build_csv | ||
save_report(REPORT_NAME, csv, extension: 'csv') | ||
end | ||
|
||
# @return [String] CSV report | ||
def build_csv | ||
sql = <<~SQL | ||
SELECT | ||
iaa_orders.start_date | ||
, iaa_orders.end_date | ||
, iaa_orders.order_number | ||
, iaa_gtcs.gtc_number AS gtc_number | ||
, upgrade.issuer AS issuer | ||
, sp.friendly_name AS friendly_name | ||
, DATE_TRUNC('month', upgrade.upgraded_at) AS year_month | ||
, COUNT(DISTINCT upgrade.user_id) AS user_count | ||
FROM iaa_orders | ||
INNER JOIN integration_usages iu ON iu.iaa_order_id = iaa_orders.id | ||
INNER JOIN integrations ON integrations.id = iu.integration_id | ||
INNER JOIN iaa_gtcs ON iaa_gtcs.id = iaa_orders.iaa_gtc_id | ||
INNER JOIN service_providers sp ON sp.issuer = integrations.issuer | ||
INNER JOIN ( | ||
SELECT DISTINCT ON (user_id) * | ||
FROM sp_upgraded_biometric_profiles | ||
) upgrade ON upgrade.issuer = integrations.issuer | ||
WHERE upgrade.upgraded_at BETWEEN iaa_orders.start_date AND iaa_orders.end_date | ||
GROUP BY iaa_orders.id, upgrade.issuer, year_month, iaa_gtcs.gtc_number, sp.friendly_name | ||
ORDER BY iaa_orders.id, year_month | ||
SQL | ||
|
||
results = transaction_with_timeout do | ||
ActiveRecord::Base.connection.select_all(sql) | ||
end | ||
|
||
CSV.generate do |csv| | ||
csv << [ | ||
'iaa_order_number', | ||
'iaa_start_date', | ||
'iaa_end_date', | ||
'issuer', | ||
'friendly_name', | ||
'year_month', | ||
'year_month_readable', | ||
'user_count', | ||
] | ||
|
||
results.each do |iaa| | ||
csv << [ | ||
IaaReportingHelper.key( | ||
gtc_number: iaa['gtc_number'], | ||
order_number: iaa['order_number'], | ||
), | ||
iaa['start_date'], | ||
iaa['end_date'], | ||
iaa['issuer'], | ||
iaa['friendly_name'], | ||
iaa['year_month'].strftime('%Y%m'), | ||
iaa['year_month'].strftime('%B %Y'), | ||
iaa['user_count'], | ||
] | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains 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 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 @@ | ||
# frozen_string_literal: true | ||
|
||
class SpUpgradedBiometricProfile < ApplicationRecord | ||
belongs_to :user | ||
end |
This file contains 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 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 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 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 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 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
14 changes: 14 additions & 0 deletions
14
db/primary_migrate/20240916202940_create_sp_upgraded_biometric_profiles.rb
This file contains 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,14 @@ | ||
class CreateSpUpgradedBiometricProfiles < ActiveRecord::Migration[7.1] | ||
def change | ||
create_table :sp_upgraded_biometric_profiles do |t| | ||
t.datetime :upgraded_at, null: false | ||
t.references :user, null: false | ||
t.string :idv_level, null: false | ||
t.string :issuer, null: false | ||
|
||
t.timestamps | ||
|
||
t.index [:issuer, :upgraded_at] | ||
end | ||
end | ||
end |
Oops, something went wrong.