Project

General

Profile

« Previous | Next » 

Revision 867cd959

Added by Dominic Cleal almost 9 years ago

fixes #10216 - sort report log messages in natural order

(cherry picked from commit 671b0b4409e2ac732613ad2af5d4cd4432f39333)

View differences:

app/models/log.rb
belongs_to :report
validates :message_id, :source_id, :report_id, :level_id, :presence => true
default_scope do
order('logs.id')
end
LEVELS = [:debug, :info, :notice, :warning, :err, :alert, :emerg, :crit]
def to_s
app/models/report.rb
cond += " and reports.status = #{status}" unless status.nil?
Log.joins(:report).where(:report_id => Report.where(cond)).delete_all
Message.where("id not IN (#{Log.select('DISTINCT message_id').to_sql})").delete_all
Source.where("id not IN (#{Log.select('DISTINCT source_id').to_sql})").delete_all
Message.where("id not IN (#{Log.unscoped.select('DISTINCT message_id').to_sql})").delete_all
Source.where("id not IN (#{Log.unscoped.select('DISTINCT source_id').to_sql})").delete_all
count = Report.where(cond).delete_all
logger.info Time.now.to_s + ": Expired #{count} Reports"
count

Also available in: Unified diff