Sha256: 2221e3f9e278d5e516c7666afc60ca1710d2ebc673e47ea4b90963524d47b91c

Contents?: true

Size: 814 Bytes

Versions: 20

Compression:

Stored size: 814 Bytes

Contents

require "digest"

module Rack::Insight

  class SQLPanel < Panel

    require "rack/insight/panels/sql_panel/panel_app"
    require "rack/insight/panels/sql_panel/query"

    def self.panel_mappings
      { "sql" => PanelApp.new }
    end

    def after_detect(method_call, timing, arguments, results)
      store(@env, QueryResult.new(arguments.first, timing.duration, method_call.backtrace, results))
    end

    def total_time(queries)
      (queries.inject(0) do |memo, query|
        memo + query.time
      end)
    end

    def heading_for_request(number)
      queries = retrieve(number)
      "#{queries.size} Queries (%.2fms)" % total_time(queries)
    end

    def content_for_request(number)
      queries = retrieve(number)
      render_template "panels/sql", :queries => queries
    end

  end

end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
rack-insight-0.6.4 lib/rack/insight/panels/sql_panel.rb
rack-insight-0.6.3 lib/rack/insight/panels/sql_panel.rb
rack-insight-0.6.2 lib/rack/insight/panels/sql_panel.rb
rack-insight-0.5.30 lib/rack/insight/panels/sql_panel.rb
rack-insight-0.5.29 lib/rack/insight/panels/sql_panel.rb
rack-insight-0.5.28 lib/rack/insight/panels/sql_panel.rb
rack-insight-0.5.27 lib/rack/insight/panels/sql_panel.rb
rack-insight-0.5.26 lib/rack/insight/panels/sql_panel.rb
rack-insight-0.5.25 lib/rack/insight/panels/sql_panel.rb
rack-insight-0.5.24 lib/rack/insight/panels/sql_panel.rb
rack-insight-0.5.23 lib/rack/insight/panels/sql_panel.rb
rack-insight-0.5.22 lib/rack/insight/panels/sql_panel.rb
rack-insight-0.5.21 lib/rack/insight/panels/sql_panel.rb
rack-insight-0.5.20 lib/rack/insight/panels/sql_panel.rb
rack-insight-0.5.19 lib/rack/insight/panels/sql_panel.rb
rack-insight-0.5.18 lib/rack/insight/panels/sql_panel.rb
rack-insight-0.5.17 lib/rack/insight/panels/sql_panel.rb
rack-insight-0.5.16 lib/rack/insight/panels/sql_panel.rb
rack-insight-0.5.15 lib/rack/insight/panels/sql_panel.rb
rack-insight-0.5.14 lib/rack/insight/panels/sql_panel.rb