mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FEATURE: clean up 1 year old and unused staged users
This commit is contained in:
parent
5f76287b18
commit
3df8f184c3
1 changed files with 18 additions and 0 deletions
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
|
Loading…
Reference in a new issue