Site Setting to customize how frequently inactive users are purged

This commit is contained in:
Robin Ward 2014-08-13 15:11:19 -04:00
parent 74d9293ca9
commit 7ed969f0c7
5 changed files with 14 additions and 2 deletions

View file

@ -0,0 +1,10 @@
module Jobs
class PurgeInactive < Jobs::Scheduled
every 1.day
def execute(args)
User.purge_inactive
end
end
end

View file

@ -11,7 +11,6 @@ module Jobs
Post.calculate_avg_time
Topic.calculate_avg_time
ScoreCalculator.new.calculate
User.purge_inactive
end
end
end

View file

@ -720,7 +720,7 @@ class User < ActiveRecord::Base
# and some sites still have those records which can't be purged.
to_destroy = User.where(active: false)
.joins('INNER JOIN user_stats AS us ON us.user_id = users.id')
.where("created_at < ?", 1.week.ago)
.where("created_at < ?", SiteSetting.purge_inactive_users_grace_period_days.days.ago)
.where('us.post_count = 0')
destroyer = UserDestroyer.new(Discourse.system_user)

View file

@ -818,6 +818,7 @@ en:
clean_up_uploads: "Remove orphan unreferenced uploads to prevent illegal hosting. WARNING: you may want to back up of your /uploads directory before enabling this setting."
clean_orphan_uploads_grace_period_hours: "Grace period (in hours) before an orphan upload is removed."
purge_deleted_uploads_grace_period_days: "Grace period (in days) before a deleted upload is erased."
purge_inactive_users_grace_period_days: "Grace period (in days) before an inactive user is deleted."
enable_s3_uploads: "Place uploads on Amazon S3 storage."
s3_upload_bucket: "The Amazon S3 bucket name that files will be uploaded into. WARNING: must be lowercase, no periods."
s3_access_key_id: "The Amazon S3 access key id that will be used to upload images."

View file

@ -704,6 +704,7 @@ uncategorized:
default: true
disable_edit_notifications: false
purge_inactive_users_grace_period_days: 7
company_full_name: 'My Unconfigured Forum Ltd.'
company_short_name: 'Unconfigured Forum'
@ -723,3 +724,4 @@ uncategorized:
privacy_topic_id:
default: -1
hidden: true