FIX: Reduce the time_read threshold to one minute. (#12159)

* FIX: Reduce the time_read threshold to one minute.

Five minutes is too much and could fill the queue with false positives.

* Update spec/jobs/enqueue_suspect_users_spec.rb

Co-authored-by: Arpit Jalan <arpit@techapj.com>

Co-authored-by: Arpit Jalan <arpit@techapj.com>
This commit is contained in:
Roman Rizzi 2021-02-20 08:25:32 -03:00 committed by GitHub
parent dbcda617b3
commit 4e716e9ce5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -16,7 +16,7 @@ module Jobs
.joins(:user_profile, :user_stat)
.where("users.created_at <= ? AND users.created_at >= ?", 1.day.ago, 6.months.ago)
.where("LENGTH(COALESCE(user_profiles.bio_raw, user_profiles.website, '')) > 0")
.where("user_stats.posts_read_count <= 1 OR user_stats.topics_entered <= 1 OR user_stats.time_read < ?", 5.minutes.to_i)
.where("user_stats.posts_read_count <= 1 OR user_stats.topics_entered <= 1 OR user_stats.time_read < ?", 1.minute.to_i)
.joins("LEFT OUTER JOIN reviewables r ON r.target_id = users.id AND r.target_type = 'User'")
.where('r.id IS NULL')
.joins(

View File

@ -90,15 +90,15 @@ describe Jobs::EnqueueSuspectUsers do
end
it 'enqueues a suspect user with not enough time read' do
suspect_user.user_stat.update!(posts_read_count: 2, topics_entered: 2, time_read: 1.minute.to_i)
suspect_user.user_stat.update!(posts_read_count: 2, topics_entered: 2, time_read: 30.seconds.to_i)
subject.execute({})
expect(ReviewableUser.count).to eq(1)
end
it 'ignores users if their time read is higher than five minutes' do
suspect_user.user_stat.update!(posts_read_count: 2, topics_entered: 2, time_read: 10.minutes.to_i)
it 'ignores users if their time read is higher than one minute' do
suspect_user.user_stat.update!(posts_read_count: 2, topics_entered: 2, time_read: 2.minutes.to_i)
subject.execute({})