-
Notifications
You must be signed in to change notification settings - Fork 166
LG-8947 Automatically reject users in fraud review after 30 days #7940
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
12 commits
Select commit
Hold shift + click to select a range
36b8002
create fraud rejection daily job
theabrad 63a8034
add test for fraud rejection job
theabrad c870452
added fraud job to cron job
theabrad 962eeee
added ability to notify user
theabrad 6186bfa
add changelog
theabrad 3f3afb4
fix typo in notify
theabrad 2f46078
add Fraud infront of analytics event
theabrad ad0710b
add index to fraud_review_pending
theabrad 3677ff7
add argument for time zone
theabrad a5b9584
Merge branch 'main' of github.com:18F/identity-idp into abrad-lg-8947…
theabrad e4c1d8f
rename index migration
theabrad fdb84b4
fix migration
theabrad 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,19 @@ | ||
| class FraudRejectionDailyJob < ApplicationJob | ||
| queue_as :low | ||
|
|
||
| def perform(_date) | ||
| profiles_eligible_for_fraud_rejection.find_each do |profile| | ||
| analytics.automatic_fraud_rejection(verified_at: profile.verified_at) | ||
| profile.reject_for_fraud(notify_user: false) | ||
| end | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def profiles_eligible_for_fraud_rejection | ||
| Profile.where( | ||
| fraud_review_pending: true, | ||
| verified_at: ..30.days.ago, | ||
| ) | ||
| 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
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
7 changes: 7 additions & 0 deletions
7
db/primary_migrate/20230307203559_add_index_on_fraud_review_pending_to_profiles.rb
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,7 @@ | ||
| class AddIndexOnFraudReviewPendingToProfiles < ActiveRecord::Migration[7.0] | ||
| disable_ddl_transaction! | ||
|
|
||
| def change | ||
| add_index :profiles, [:fraud_review_pending], algorithm: :concurrently | ||
| 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
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,25 @@ | ||
| require 'rails_helper' | ||
|
|
||
| RSpec.describe FraudRejectionDailyJob do | ||
| subject(:job) { FraudRejectionDailyJob.new } | ||
| let(:job_analytics) { FakeAnalytics.new } | ||
|
|
||
| before do | ||
| allow(job).to receive(:analytics).and_return(job_analytics) | ||
| end | ||
|
|
||
| describe '#perform' do | ||
| it 'rejects profiles which have been review pending for more than 30 days' do | ||
| create(:profile, fraud_review_pending: true, verified_at: 31.days.ago) | ||
| create(:profile, fraud_review_pending: true, verified_at: 20.days.ago) | ||
|
|
||
| rejected_profiles = Profile.where(fraud_rejection: true) | ||
|
|
||
| expect { job.perform(Time.zone.today) }.to change { rejected_profiles.count }.by(1) | ||
| expect(job_analytics).to have_logged_event( | ||
| 'Fraud: Automatic Fraud Rejection', | ||
| verified_at: rejected_profiles.first.verified_at, | ||
| ) | ||
| 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
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.
we don't have an index on
verified_at, can we add one? otherwise this will be a table scanThere 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.
or on
fraud_review_pendingjust something so that we don't scan the whole tableThere 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.
Ok I'll place it on fraud_review_pending we are looking to replace the boolean with a timestamp further down the line.