FEATURE: clean up 1 year old and unused staged users

This commit is contained in:
Régis Hanol 2016-05-16 22:13:23 +02:00
parent 5f76287b18
commit 3df8f184c3

View file

@ -0,0 +1,18 @@
module Jobs
class CleanUpUnusedStagedUsers < Jobs::Scheduled
every 1.day
def execute(args)
destroyer = UserDestroyer.new(Discourse.system_user)
User.joins(:user_stat)
.where(staged: true)
.where("users.created_at < ?", 1.year.ago)
.where("user_stats.post_count = 0")
.find_each { |user| destroyer.destroy(user) }
end
end
end