Class: SqlReporter::Reporters::Reporter
- Inherits:
-
Object
- Object
- SqlReporter::Reporters::Reporter
- Defined in:
- lib/sql_reporter/reporters/reporter.rb
Direct Known Subclasses
Constant Summary collapse
- EXTENSION =
''
Instance Attribute Summary collapse
-
#disable_console ⇒ Object
readonly
Returns the value of attribute disable_console.
-
#feature ⇒ Object
Returns the value of attribute feature.
-
#fname0 ⇒ Object
Returns the value of attribute fname0.
-
#fname1 ⇒ Object
Returns the value of attribute fname1.
-
#io ⇒ Object
Returns the value of attribute io.
-
#master ⇒ Object
Returns the value of attribute master.
-
#master_max_count ⇒ Object
readonly
Returns the value of attribute master_max_count.
-
#output ⇒ Object
Returns the value of attribute output.
Instance Method Summary collapse
- #generate_report ⇒ Object
-
#initialize(parser_hsh) ⇒ Reporter
constructor
A new instance of Reporter.
- #output_file ⇒ Object
Constructor Details
#initialize(parser_hsh) ⇒ Reporter
Returns a new instance of Reporter.
6 7 8 9 10 11 12 |
# File 'lib/sql_reporter/reporters/reporter.rb', line 6 def initialize(parser_hsh) @fname0, @master = parser_hsh.entries[0] @fname1, @feature = parser_hsh.entries[1] @master_max_count = @master.values.map(&:count).max @output = parser_hsh[:output] if parser_hsh.key?(:output) @disable_console = parser_hsh[:disable_console] if parser_hsh.key?(:disable_console) end |
Instance Attribute Details
#disable_console ⇒ Object (readonly)
Returns the value of attribute disable_console.
15 16 17 |
# File 'lib/sql_reporter/reporters/reporter.rb', line 15 def disable_console @disable_console end |
#feature ⇒ Object
Returns the value of attribute feature.
14 15 16 |
# File 'lib/sql_reporter/reporters/reporter.rb', line 14 def feature @feature end |
#fname0 ⇒ Object
Returns the value of attribute fname0.
14 15 16 |
# File 'lib/sql_reporter/reporters/reporter.rb', line 14 def fname0 @fname0 end |
#fname1 ⇒ Object
Returns the value of attribute fname1.
14 15 16 |
# File 'lib/sql_reporter/reporters/reporter.rb', line 14 def fname1 @fname1 end |
#io ⇒ Object
Returns the value of attribute io.
14 15 16 |
# File 'lib/sql_reporter/reporters/reporter.rb', line 14 def io @io end |
#master ⇒ Object
Returns the value of attribute master.
14 15 16 |
# File 'lib/sql_reporter/reporters/reporter.rb', line 14 def master @master end |
#master_max_count ⇒ Object (readonly)
Returns the value of attribute master_max_count.
15 16 17 |
# File 'lib/sql_reporter/reporters/reporter.rb', line 15 def master_max_count @master_max_count end |
#output ⇒ Object
Returns the value of attribute output.
14 15 16 |
# File 'lib/sql_reporter/reporters/reporter.rb', line 14 def output @output end |
Instance Method Details
#generate_report ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/sql_reporter/reporters/reporter.rb', line 17 def generate_report setup_io before_generate_report totals = [] before_decreases totals << summary_for_selected_differences(master.keys | feature.keys) do |key| master[key] && feature[key] && ( master[key].count > feature[key].count || (master[key].count == feature[key].count && master[key].cached_count > feature[key].cached_count) ) end before_increases totals << summary_for_selected_differences(master.keys | feature.keys) do |key| master[key] && feature[key] && ( master[key].count < feature[key].count || (master[key].count == feature[key].count && master[key].cached_count < feature[key].cached_count) ) end before_spawned totals << summary_for_selected_differences(feature.keys - master.keys) { |key| feature[key] } before_gone totals << summary_for_selected_differences(master.keys - feature.keys) { |key| master[key] } before_summary totals_sum = totals.reduce(SqlReporter::Total.new(0,0,0)) {|acc, t| acc + t} additional_data = {} additional_data[:reduced] = totals.reduce(0) {|acc, t| acc + t.query_drop} additional_data[:spawned] = totals.reduce(0) {|acc, t| acc + t.query_gain} generate_summary(totals_sum, **additional_data) after_generate_report end |
#output_file ⇒ Object
52 53 54 |
# File 'lib/sql_reporter/reporters/reporter.rb', line 52 def output_file (output || 'comparison') + self.class::EXTENSION end |