Project

General

Profile

« Previous | Next » 

Revision 3642120b

Added by Ohad Levy over 14 years ago

  • ID 3642120bef2f85b35402a11b54357dbe1bb2a109

Improve the way reports gets deleted, this should be way faster

View differences:

app/models/report.rb
# We do not keep more than 24 hours of history in the database
def self.expire_reports
expired = Report.find(:all, :conditions => ["reported_at < ?",(Time.now.utc - 24.hours)])
logger.info Time.now.to_s + ": Expiring #{expired.size} reports"
expired.each{|report| report.destroy}
cond = ["reported_at < ?",(Time.now.utc - 24.hours)]
logger.info Time.now.to_s + ": Expiring #{Report.count(:conditions => cond)} reports"
Report.delete_all(cond)
end
end

Also available in: Unified diff