Class: ActiveRecordQueryCount::Printer::HtmlCompare
- Defined in:
- lib/active_record_query_count/printer/html_compare.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_1:, data_2:) ⇒ HtmlCompare
constructor
A new instance of HtmlCompare.
-
#print ⇒ Object
TODO: the sql on the data_1 and data_2 of the same location could be different in the html we only show the sql of the first script It maybe better to remove the sql from the table in this case.
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_1:, data_2:) ⇒ HtmlCompare
Returns a new instance of HtmlCompare.
10 11 12 13 14 15 16 |
# File 'lib/active_record_query_count/printer/html_compare.rb', line 10 def initialize data_1:, data_2: super() @script_1_name = data_1.keys.first @script_2_name = data_2.keys.first @data_1 = data_1[@script_1_name] @data_2 = data_2[@script_2_name] end |
Instance Method Details
#print ⇒ Object
TODO: the sql on the data_1 and data_2 of the same location could be different
in the html we only show the sql of the first script
It maybe better to remove the sql from the table in this case
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/active_record_query_count/printer/html_compare.rb', line 21 def print # used by binding on erb templates data_1 = sort_data(@data_1) data_2 = sort_data(@data_2) tables = data_1.keys | data_2.keys total_query_count_1 = data_1.values.sum { |v| v[:count] } total_query_count_2 = data_2.values.sum { |v| v[:count] } chart_data = generate_chart_js_data_compare(data_1, data_2) # end html_dest = generate_html(binding) open_file(html_dest) end |