Class: ActiveRecordQueryCount::Printer::Console
- Defined in:
- lib/active_record_query_count/printer/console.rb
Constant Summary
Constants inherited from Base
Base::BASE_QUERY_COUNTER_PATH, Base::CHART_JS_CONTENT, Base::CSS_PATH, Base::INJECT_TEMPLATE_PATH, Base::JS_PATH, Base::TEMPLATE_COMPARING_PATH, Base::TEMPLATE_PATH
Instance Method Summary collapse
-
#initialize(data:) ⇒ Console
constructor
A new instance of Console.
- #print ⇒ Object
Methods inherited from Base
#base_query_counter_content, #chart_js_content, #css_content, #filter_data, #inject_template_content, #js_content, #open_file, #sort_data, #template_comparing_content, #template_content
Constructor Details
#initialize(data:) ⇒ Console
Returns a new instance of Console.
6 7 8 9 |
# File 'lib/active_record_query_count/printer/console.rb', line 6 def initialize data: super() @data = data end |
Instance Method Details
#print ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/active_record_query_count/printer/console.rb', line 11 def print data = filter_data(@data) puts '[ActiveRecordQueryCount] Query count per table:'.colorize(:blue) puts "Total query count: #{data.values.sum { |v| v[:count] }}\n\n" puts "All tables with less than #{Configuration.ignore_table_count} queries are ignored. \n\n" puts "For each table, the top #{Configuration.max_locations_per_table} locations with the most queries will be shown.\n\n" data.each do |category, info| puts "Table #{category.colorize(:cyan)}" puts " Total query count: #{info[:count].to_s.colorize(:blue)}" puts ' Locations where the table was called:' info[:location].each do |loc, details| puts " - File location: #{loc}" puts " Query count: #{details[:count].to_s.colorize(:blue)}" puts " Total Duration(ms): #{details[:duration]}" end puts end end |