mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
FEATURE: improve suspect user discovery
This commit is contained in:
@ -84,7 +84,7 @@ class AdminUserIndexQuery
|
|||||||
.human_users
|
.human_users
|
||||||
.joins(:user_profile, :user_stat)
|
.joins(:user_profile, :user_stat)
|
||||||
.where("users.created_at <= ?", 1.day.ago)
|
.where("users.created_at <= ?", 1.day.ago)
|
||||||
.where("LENGTH(COALESCE(user_profiles.bio_raw, '')) > 0")
|
.where("LENGTH(COALESCE(user_profiles.bio_raw, user_profiles.website, '')) > 0")
|
||||||
.where("user_stats.posts_read_count <= 1 AND user_stats.topics_entered <= 1")
|
.where("user_stats.posts_read_count <= 1 AND user_stats.topics_entered <= 1")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -92,14 +92,23 @@ describe AdminUserIndexQuery do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe 'with a suspected user' do
|
describe 'with a suspected user' do
|
||||||
fab!(:user) { Fabricate(:active_user, created_at: 1.day.ago) }
|
|
||||||
fab!(:bot) { Fabricate(:active_user, id: -10, created_at: 1.day.ago) }
|
fab!(:bot) { Fabricate(:active_user, id: -10, created_at: 1.day.ago) }
|
||||||
|
fab!(:regular_user) { Fabricate(:user, created_at: 1.day.ago) }
|
||||||
|
fab!(:user_with_bio) { Fabricate(:active_user, created_at: 1.day.ago) }
|
||||||
|
fab!(:user_with_website) { Fabricate(:user, created_at: 1.day.ago) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
user_with_website.user_profile.website = 'https://example.com'
|
||||||
|
user_with_website.user_profile.save!
|
||||||
|
end
|
||||||
|
|
||||||
it 'finds the suspected user' do
|
it 'finds the suspected user' do
|
||||||
bot
|
bot
|
||||||
user
|
regular_user
|
||||||
|
user_with_bio
|
||||||
|
user_with_website
|
||||||
query = AdminUserIndexQuery.new(query: 'suspect')
|
query = AdminUserIndexQuery.new(query: 'suspect')
|
||||||
expect(query.find_users).to eq([user])
|
expect(query.find_users).to contain_exactly(user_with_bio, user_with_website)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user