clean up exports weekly
This commit is contained in:
parent
d0736a06b6
commit
b0f44dcdf3
|
@ -11,6 +11,7 @@ module Jobs
|
|||
Post.calculate_avg_time
|
||||
Topic.calculate_avg_time
|
||||
ScoreCalculator.new.calculate
|
||||
ExportCsv.remove_old_exports # delete exported CSV files older than 2 days
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,6 +9,15 @@ class ExportCsv
|
|||
end
|
||||
end
|
||||
|
||||
def self.remove_old_exports
|
||||
dir = Dir.new(ExportCsv.base_directory)
|
||||
dir.each do |file|
|
||||
if (File.mtime(File.join(ExportCsv.base_directory, file)) < 2.days.ago)
|
||||
File.delete(File.join(ExportCsv.base_directory, file))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.base_directory
|
||||
File.join(Rails.root, "public", "uploads", "csv_exports", RailsMultisite::ConnectionManagement.current_db)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue