Class | AppException |
In: |
app/models/app_exception.rb
|
Parent: | ActiveRecord::Base |
Model class for App Exceptions. This model helps to show the details of the exceptions tracked by the server.
Take App.id as argument and returns count of distinct closed exceptions for an Application
# File app/models/app_exception.rb, line 35 35: def count_closed(app_id) 36: count(:exception_message, :conditions => {:app_id => app_id, :exception_status => CLOSED_EXCEPTION}, :distinct => true) 37: end
Take App.id as argument and returns count of distinct ignored exceptions for an Application
# File app/models/app_exception.rb, line 40 40: def count_ignored(app_id) 41: count(:exception_message, :conditions => {:app_id => app_id, :exception_status => IGNORED_EXCEPTION}, :distinct => true) 42: end
Take App.id as argument and returns count of distinct open exceptions for an Application
# File app/models/app_exception.rb, line 30 30: def count_open(app_id) 31: count(:exception_message, :conditions => {:app_id => app_id, :exception_status => OPEN_EXCEPTION}, :distinct => true) 32: end
Gives the array of the five (open|closed|ignored) exceptions starting from the value of varriable ‘start’ for an application.
# File app/models/app_exception.rb, line 25 25: def get_all(exception_status, app_id, start = 0) 26: all(:select => 'id, exception_message, exception_class, controller, method, wall_time, count(*) as count', :conditions => ['app_id = ? and exception_status = ?', app_id, exception_status], :group => 'exception_message', :limit => "#{start}, 5", :order => 'wall_time desc') 27: end
Gives the details af an exception with the help of its exception_message for a specific application.
# File app/models/app_exception.rb, line 60 60: def get_exception_details_by_exception_message(exception_message, app_id) 61: exception = find(:all, :conditions => ["exception_message = ? and app_id = ?", exception_message, app_id], :order => 'wall_time desc') 62: return exception 63: end
Gives the details of the exception with some specific id.
# File app/models/app_exception.rb, line 54 54: def get_exception_details_by_id(exception_id) 55: exception = find(:first, :conditions => ["id = ?", exception_id]) 56: return exception 57: end
Update all exceptions status for a matching application and exception message
# File app/models/app_exception.rb, line 45 45: def update_status_to(status, app_name, exception_message) 46: if app = App.first(:select => 'id', :conditions => {:name => app_name}) 47: app_id = app.id 48: exceptions_id_array = all(:select =>'id', :conditions => ["exception_message = ? and app_id = ?", exception_message, app_id]).collect { |e| e.id } 49: update_all(["exception_status = ?",status], ["id in (#{exceptions_id_array.join(',')})"]) 50: end 51: end