FIX: Do not include non-human users on suspected users list.

https://meta.discourse.org/t/discobot-is-a-suspect-user/70558
This commit is contained in:
Guo Xiang Tan 2017-09-26 15:04:08 +08:00
parent 6f5051861c
commit c25730935e
2 changed files with 3 additions and 0 deletions

View File

@ -81,6 +81,7 @@ class AdminUserIndexQuery
where_conds << "user_stats.posts_read_count <= 1 AND user_stats.topics_entered <= 1" where_conds << "user_stats.posts_read_count <= 1 AND user_stats.topics_entered <= 1"
@query.activated @query.activated
.human_users
.references(:user_stats) .references(:user_stats)
.includes(:user_profile) .includes(:user_profile)
.where("COALESCE(user_profiles.bio_raw, '') != ''") .where("COALESCE(user_profiles.bio_raw, '') != ''")

View File

@ -90,8 +90,10 @@ describe AdminUserIndexQuery do
describe 'with a suspected user' do describe 'with a suspected user' do
let(:user) { Fabricate(:active_user, created_at: 1.day.ago) } let(:user) { Fabricate(:active_user, created_at: 1.day.ago) }
let(:bot) { Fabricate(:active_user, id: -10, created_at: 1.day.ago) }
it 'finds the suspected user' do it 'finds the suspected user' do
bot
user user
query = AdminUserIndexQuery.new(query: 'suspect') query = AdminUserIndexQuery.new(query: 'suspect')
expect(query.find_users).to eq([user]) expect(query.find_users).to eq([user])