-
Notifications
You must be signed in to change notification settings - Fork 166
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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,75 @@ | ||
| 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| | ||
| if profile.fraud_pending_reason.blank? | ||
| warn "Profile ##{profile.id} does not have a fraud pending reason!" | ||
| break | ||
| end | ||
|
|
||
| warn "#{profile.id},#{profile.fraud_review_pending_at},#{profile.fraud_rejection_at}" | ||
| profile.update!(fraud_review_pending_at: nil, fraud_rejection_at: nil) if update_profiles | ||
| 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 |
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.
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.