FIX: Avoid `destroy_all` in `Jobs::CleanUpUploads`.

`destroy_all` loads all the relation into memory as once.

See https://github.com/rails/rails/issues/22510
This commit is contained in:
Guo Xiang Tan 2018-07-02 12:41:53 +08:00
parent 27c018e75c
commit f7322c05ad
1 changed files with 1 additions and 1 deletions

View File

@ -10,7 +10,7 @@ module Jobs
.where("retain_hours IS NULL OR created_at < current_timestamp - interval '1 hour' * retain_hours") .where("retain_hours IS NULL OR created_at < current_timestamp - interval '1 hour' * retain_hours")
.where("created_at < ?", grace_period.hour.ago) .where("created_at < ?", grace_period.hour.ago)
.where(url: "") .where(url: "")
.destroy_all .find_each(&:destroy!)
return unless SiteSetting.clean_up_uploads? return unless SiteSetting.clean_up_uploads?