mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 23:07:28 +08:00
FEATURE: clean up 1 year old and unused staged users
This commit is contained in:
18
app/jobs/scheduled/clean_up_unused_staged_users.rb
Normal file
18
app/jobs/scheduled/clean_up_unused_staged_users.rb
Normal 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
|
Reference in New Issue
Block a user