class SqlReporter::Reporters::ExcelReporter
Constants
- EXTENSION
- HEADERS
Attributes
totals[R]
Protected Instance Methods
after_generate_report()
click to toggle source
# File lib/sql_reporter/reporters/excel_reporter.rb, line 26 def after_generate_report @totals = totals @lines = lines.sort_by {|d| d.sort_score(master_max_count) }.reverse book = Spreadsheet::Workbook.new sheet = book.create_worksheet(name: "Comparison Report #{fname0} -> #{fname1}") sheet.row(0).concat HEADERS lines.each_with_index do |l, i| sheet.row(i + 1).concat [l.query_name, l.master.count, l.feature.count, l.master.duration_formatted, l.feature.duration_formatted] end totals_row_no = lines.size + 1 accumulated_row = totals_row_no + 2 sheet[totals_row_no, 0] = 'Totals:' sheet[totals_row_no, 1] = lines.reduce(0) {|acc, l| acc + l.master.count } sheet[totals_row_no, 2] = lines.reduce(0) {|acc, l| acc + l.feature.count } sheet[totals_row_no, 3] = lines.reduce(0) {|acc, l| acc + l.master.duration_formatted } sheet[totals_row_no, 4] = lines.reduce(0) {|acc, l| acc + l.feature.duration_formatted } sheet[accumulated_row, 1] = 'Count Increase:' sheet[accumulated_row, 2] = sheet[totals_row_no, 2] - sheet[totals_row_no, 1] sheet[accumulated_row, 3] = 'Time Increase:' sheet[accumulated_row, 4] = sheet[totals_row_no, 4] - sheet[totals_row_no, 3] bold = Spreadsheet::Format.new(weight: :bold) [totals_row_no, accumulated_row].each do |row| 5.times { |x| sheet.row(row).set_format(x, bold) } end book.write "./#{output_file}" end
before_decreases()
click to toggle source
# File lib/sql_reporter/reporters/excel_reporter.rb, line 57 def before_decreases end
before_generate_report()
click to toggle source
# File lib/sql_reporter/reporters/excel_reporter.rb, line 22 def before_generate_report @lines = [] end
before_gone()
click to toggle source
# File lib/sql_reporter/reporters/excel_reporter.rb, line 60 def before_gone end
before_increases()
click to toggle source
# File lib/sql_reporter/reporters/excel_reporter.rb, line 54 def before_increases end
before_spawned()
click to toggle source
# File lib/sql_reporter/reporters/excel_reporter.rb, line 63 def before_spawned end
before_summary()
click to toggle source
# File lib/sql_reporter/reporters/excel_reporter.rb, line 66 def before_summary end
generate_query_line(diff)
click to toggle source
# File lib/sql_reporter/reporters/excel_reporter.rb, line 18 def generate_query_line(diff) lines << diff end
generate_summary(totals, **kwargs)
click to toggle source
# File lib/sql_reporter/reporters/excel_reporter.rb, line 14 def generate_summary(totals, **kwargs) @totals = totals end