2016-02-08 12:47:35 -05:00
|
|
|
module Jobs
|
|
|
|
|
|
|
|
class CleanUpEmailLogs < Jobs::Scheduled
|
|
|
|
every 1.day
|
|
|
|
|
|
|
|
def execute(args)
|
2016-02-08 16:18:52 -05:00
|
|
|
return if SiteSetting.delete_email_logs_after_days <= 0
|
2016-02-08 12:47:35 -05:00
|
|
|
|
2016-02-08 16:18:52 -05:00
|
|
|
threshold = SiteSetting.delete_email_logs_after_days.days.ago
|
2016-02-08 12:47:35 -05:00
|
|
|
|
|
|
|
EmailLog.where(reply_key: nil)
|
2017-07-27 21:20:09 -04:00
|
|
|
.where("created_at < ?", threshold)
|
|
|
|
.delete_all
|
2016-02-08 12:47:35 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|