Skip to content

A platform for community discussion. Free, open, simple.

fix purge unactivated users subquery

Arpit Jalandb67c87916a5
diff --git a/app/models/user.rb b/app/models/user.rb
index 0168a7b985b..a0022b7db56 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1223,7 +1223,7 @@ class User < ActiveRecord::Base
.where("created_at < ?", SiteSetting.purge_unactivated_users_grace_period_days.days.ago)
.where("NOT admin AND NOT moderator")
.where("NOT EXISTS
- (SELECT 1 FROM topic_allowed_users tu JOIN topics t ON t.id = tu.topic_id AND t.user_id > 0 WHERE tu.user_id = users.id)
+ (SELECT 1 FROM topic_allowed_users tu JOIN topics t ON t.id = tu.topic_id AND t.user_id > 0 WHERE tu.user_id = users.id LIMIT 1)
")
.limit(200)
.find_each do |user|