2016-02-09 01:47:35 +08:00
|
|
|
module Jobs
|
|
|
|
|
|
|
|
class CleanUpEmailLogs < Jobs::Scheduled
|
|
|
|
every 1.day
|
|
|
|
|
|
|
|
def execute(args)
|
2016-02-09 05:18:52 +08:00
|
|
|
return if SiteSetting.delete_email_logs_after_days <= 0
|
2016-02-09 01:47:35 +08:00
|
|
|
|
2016-02-09 05:18:52 +08:00
|
|
|
threshold = SiteSetting.delete_email_logs_after_days.days.ago
|
2016-02-09 01:47:35 +08:00
|
|
|
|
2018-07-18 16:28:44 +08:00
|
|
|
EmailLog.where("reply_key IS NULL")
|
2017-07-28 09:20:09 +08:00
|
|
|
.where("created_at < ?", threshold)
|
|
|
|
.delete_all
|
2018-07-24 12:55:43 +08:00
|
|
|
|
|
|
|
SkippedEmailLog.where("created_at < ?", threshold).delete_all
|
2016-02-09 01:47:35 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|