Sha256: 0f75f42915a6a762ab54828db966bde5e3c096c683cb10731f2a7663241b126c

Contents?: true

Size: 1.27 KB

Versions: 10

Compression:

Stored size: 1.27 KB

Contents

module ActiveTracker
  class ExceptionsController < ActiveTracker::BaseController
    def index
      ts = Time.current.to_f
      @exceptions = ActiveTracker::Model.all("Exception")
      filter_exceptions if params[:q].present?
      duration = (Time.current.to_f - ts) * 1000
      @exceptions, @pagination = ActiveTracker::Model.paginate(@exceptions, params[:page], ActiveTracker::Configuration.per_page)
      @duration = duration
    end

    def show
      @exception = ActiveTracker::Model.find(params[:id])
      @requests = @exception.at_requests.map {|id| ActiveTracker::Model.find(id) rescue nil}.compact
    end

    private

    def filter_exceptions
      filters = params[:q].split(/\s+/)
      filtered = @exceptions.select do |exception|
        acceptable = true
        filters.each do |filter|
          if filter[":"]
            key,value = filter.split(":")
            if exception.tags[key.to_sym]&.downcase != value&.downcase
              acceptable = false
            end
          else
            unless (exception.tags[:class_name] || "").downcase[filter.downcase] || (exception.message || "").downcase[filter.downcase]
              acceptable = false
            end
          end
        end
        acceptable
      end
      @exceptions = filtered
    end

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
activetracker-0.4.9 app/controllers/active_tracker/exceptions_controller.rb
activetracker-0.4.8 app/controllers/active_tracker/exceptions_controller.rb
activetracker-0.4.7 app/controllers/active_tracker/exceptions_controller.rb
activetracker-0.4.6 app/controllers/active_tracker/exceptions_controller.rb
activetracker-0.4.5 app/controllers/active_tracker/exceptions_controller.rb
activetracker-0.4.4 app/controllers/active_tracker/exceptions_controller.rb
activetracker-0.4.3 app/controllers/active_tracker/exceptions_controller.rb
activetracker-0.4.2 app/controllers/active_tracker/exceptions_controller.rb
activetracker-0.4.1 app/controllers/active_tracker/exceptions_controller.rb
activetracker-0.4.0 app/controllers/active_tracker/exceptions_controller.rb