Class: Groonga::QueryLog::Analyzer::Reporter

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/groonga/query-log/analyzer/reporter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(statistics) ⇒ Reporter

Returns a new instance of Reporter.



28
29
30
31
32
33
34
35
36
# File 'lib/groonga/query-log/analyzer/reporter.rb', line 28

def initialize(statistics)
  @statistics = statistics
  @report_summary = true
  @output = $stdout
  @slow_operation_threshold =
    Statistic::DEFAULT_SLOW_OPERATION_THRESHOLD
  @slow_response_threshold =
    Statistic::DEFAULT_SLOW_RESPONSE_THRESHOLD
end

Instance Attribute Details

#outputObject

Returns the value of attribute output.



26
27
28
# File 'lib/groonga/query-log/analyzer/reporter.rb', line 26

def output
  @output
end

#slow_operation_thresholdObject

Returns the value of attribute slow_operation_threshold.



27
28
29
# File 'lib/groonga/query-log/analyzer/reporter.rb', line 27

def slow_operation_threshold
  @slow_operation_threshold
end

#slow_response_thresholdObject

Returns the value of attribute slow_response_threshold.



27
28
29
# File 'lib/groonga/query-log/analyzer/reporter.rb', line 27

def slow_response_threshold
  @slow_response_threshold
end

Instance Method Details

#apply_options(options) ⇒ Object



38
39
40
41
42
43
44
45
46
47
# File 'lib/groonga/query-log/analyzer/reporter.rb', line 38

def apply_options(options)
  self.output = options[:output] || @output
  unless options[:report_summary].nil?
    @report_summary = options[:report_summary]
  end
  @slow_operation_threshold =
    options[:slow_operation_threshold] || @slow_operation_threshold
  @slow_response_threshold =
    options[:slow_response_threshold] || @slow_response_threshold
end

#eachObject



54
55
56
57
58
# File 'lib/groonga/query-log/analyzer/reporter.rb', line 54

def each
  @statistics.each do |statistic|
    yield statistic
  end
end

#reportObject



60
61
62
63
64
65
# File 'lib/groonga/query-log/analyzer/reporter.rb', line 60

def report
  setup do
    report_summary if @report_summary
    report_statistics
  end
end

#report_statisticsObject



67
68
69
70
71
# File 'lib/groonga/query-log/analyzer/reporter.rb', line 67

def report_statistics
  each do |statistic|
    report_statistic(statistic)
  end
end