-
Notifications
You must be signed in to change notification settings - Fork 167
LG-9968 Only write to fraud_review_pending_at when a user starts the fraud review process #8821
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| namespace :profiles do | ||
| desc 'If a profile is in GPO and fraud pending state, move it out of fraud pending state' | ||
|
|
||
| ## | ||
| # Usage: | ||
| # | ||
| # Print pending updates | ||
| # bundle exec rake profiles:backfill_fraud_review_pending_at | ||
| # | ||
| # Commit updates | ||
| # bundle exec rake profiles:backfill_fraud_review_pending_at UPDATE_PROFILES=true | ||
| # | ||
| task backfill_fraud_review_pending_at: :environment do |_task, _args| | ||
| ActiveRecord::Base.connection.execute('SET statement_timeout = 60000') | ||
|
|
||
| update_profiles = ENV['UPDATE_PROFILES'] == 'true' | ||
|
|
||
| profiles = Profile.where( | ||
| 'fraud_review_pending_at IS NOT NULL OR fraud_rejection_at IS NOT NULL', | ||
| ).where.not( | ||
| gpo_verification_pending_at: nil, | ||
| ) | ||
|
|
||
| profiles.each do |profile| | ||
| warn "#{profile.id},#{profile.fraud_review_pending_at},#{profile.fraud_rejection_at}" | ||
| profile.update!(fraud_review_pending_at: nil) if update_profiles | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this confirm that fraud_pending_reason is set? And, should it set fraud_rejection_at to nil?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I'll add a warn if |
||
| end | ||
| end | ||
|
|
||
| ## | ||
| # Usage: | ||
| # | ||
| # Rollback the above: | ||
| # | ||
| # export BACKFILL_OUTPUT='<backfill_output>' | ||
| # bundle exec rake profiles:rollback_backfill_fraud_review_pending_at | ||
| # | ||
| task rollback_backfill_fraud_review_pending_at: :environment do |_task, _args| | ||
| ActiveRecord::Base.connection.execute('SET statement_timeout = 60000') | ||
|
|
||
| profile_data = ENV['BACKFILL_OUTPUT'].split("\n").map do |profile_row| | ||
| profile_row.split(',') | ||
| end | ||
|
|
||
| warn "Updating #{profile_data.count} records" | ||
| profile_data.each do |profile_datum| | ||
| profile_id, fraud_review_pending_at, fraud_rejection_at = profile_datum | ||
| Profile.where(id: profile_id).update!( | ||
| fraud_review_pending_at: fraud_review_pending_at, | ||
| fraud_rejection_at: fraud_rejection_at, | ||
| ) | ||
| end | ||
| end | ||
|
|
||
| ## | ||
| # Usage: | ||
| # bundle exec rake profiles:validate_backfill_fraud_review_pending_at | ||
| # | ||
| task validate_backfill_fraud_review_pending_at: :environment do |_task, _args| | ||
| ActiveRecord::Base.connection.execute('SET statement_timeout = 60000') | ||
|
|
||
| profiles = Profile.where( | ||
| 'fraud_review_pending_at IS NOT NULL OR fraud_rejection_at IS NOT NULL', | ||
| ).where.not( | ||
| gpo_verification_pending_at: nil, | ||
| ) | ||
|
|
||
| warn "fraud_pending_reason backfill left #{profiles.count} rows" | ||
| end | ||
| end | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some tracing through the code and couldn't find where
deactivate_for_fraud_reviewwill be called once the user enters their gpo code.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That occurs in
GpoVerifyForm#submit.