diff --git a/lib/admin_user_index_query.rb b/lib/admin_user_index_query.rb index 83bc4dc84ae..2341b4d4e3d 100644 --- a/lib/admin_user_index_query.rb +++ b/lib/admin_user_index_query.rb @@ -76,18 +76,13 @@ class AdminUserIndexQuery end def suspect_users - where_conds = [] - - # One signal: no reading yet the user has bio text - where_conds << "user_stats.posts_read_count <= 1 AND user_stats.topics_entered <= 1" - - @query.activated + @query + .activated .human_users - .references(:user_stats) - .includes(:user_profile) - .where("COALESCE(user_profiles.bio_raw, '') != ''") - .where('users.created_at <= ?', 1.day.ago) - .where(where_conds.map { |c| "(#{c})" }.join(" OR ")) + .joins(:user_profile, :user_stat) + .where("users.created_at <= ?", 1.day.ago) + .where("LENGTH(COALESCE(user_profiles.bio_raw, '')) > 0") + .where("user_stats.posts_read_count <= 1 AND user_stats.topics_entered <= 1") end def filter_by_query_classification