Class: Rack::Insight::SQLPanel

Inherits:
Panel
  • Object
show all
Defined in:
lib/rack/insight/panels/sql_panel.rb,
lib/rack/insight/panels/sql_panel/query.rb,
lib/rack/insight/panels/sql_panel/panel_app.rb

Defined Under Namespace

Classes: ExplainResult, PanelApp, ProfileResult, QueryResult

Instance Attribute Summary

Attributes inherited from Panel

#request

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Panel

#after, #before, #bool_prop, #call, #camelized_name, #content, current_panel_file, excluded, file_index, from_file, #handle_error_for, #has_content?, #has_custom_probes?, has_table, #has_table?, #heading, inherited, #initialize, #inspect, #is_magic?, #is_probing?, #name, #panel_app, panel_exclusion, #render, set_sub_class_template_root, #underscored_name

Methods included from Database::EigenClient

included

Methods included from Instrumentation::EigenClient

included

Methods included from Logging

logger, verbose, verbosity

Methods included from Instrumentation::Client

#before_detect, #probe, #request_finish, #request_start

Methods included from Database::RequestDataClient

#count, #key_sql_template, #retrieve, #store, #table_length, #table_setup

Methods included from Render

#compile, #compile!, #compiled_source, #method_name, #method_name_without_locals, #render_template, #signed_params

Constructor Details

This class inherits a constructor from Rack::Insight::Panel

Class Method Details

.panel_mappingsObject



10
11
12
# File 'lib/rack/insight/panels/sql_panel.rb', line 10

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

Instance Method Details

#after_detect(method_call, timing, arguments, results) ⇒ Object



14
15
16
# File 'lib/rack/insight/panels/sql_panel.rb', line 14

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

#content_for_request(number) ⇒ Object



29
30
31
32
# File 'lib/rack/insight/panels/sql_panel.rb', line 29

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

#heading_for_request(number) ⇒ Object



24
25
26
27
# File 'lib/rack/insight/panels/sql_panel.rb', line 24

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

#total_time(queries) ⇒ Object



18
19
20
21
22
# File 'lib/rack/insight/panels/sql_panel.rb', line 18

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