adds expired days in constant

This commit is contained in:
zmagod 2017-04-04 10:16:54 +02:00
parent e1ee53eeb5
commit e016bda9d2
2 changed files with 7 additions and 3 deletions

View file

@ -223,6 +223,8 @@ class Constants
href src width height alt cite datetime title class name xml:lang abbr style
).freeze
EXPORTABLE_ZIP_EXPIRATION_DAYS = 7
# Very basic regex to check for validity of emails
BASIC_EMAIL_REGEX = URI::MailTo::EMAIL_REGEXP

View file

@ -1,7 +1,9 @@
namespace :exportable_items do
desc 'Removes exportable zip files if older than 7 days'
desc 'Removes exportable zip files'
task cleanup: :environment do
ZipExport.where('created_at < ?', 7.days.ago).destroy_all
puts "All exportable zip files older than '#{7.days.ago}' have been removed"
num = Constants::EXPORTABLE_ZIP_EXPIRATION_DAYS
ZipExport.where('created_at < ?', num.days.ago).destroy_all
puts "All exportable zip files older than " \
"'#{num.days.ago}' have been removed"
end
end