class MetricFu::Hotspot

Public Class Methods

analyzer_for_metric(metric) click to toggle source
# File lib/metric_fu/metrics/hotspots/hotspot.rb, line 13
def self.analyzer_for_metric(metric)
  @analyzers.fetch(metric.to_sym) do
    message = "Unknown metric #{metric}. We only know #{@analyzers.keys.inspect}"
    fail MetricFu::AnalysisError, message
  end
end
analyzers() click to toggle source
# File lib/metric_fu/metrics/hotspots/hotspot.rb, line 10
def self.analyzers
  @analyzers.values
end
inherited(subclass) click to toggle source
# File lib/metric_fu/metrics/hotspots/hotspot.rb, line 19
def self.inherited(subclass)
  mf_debug "Adding #{subclass} to #{@analyzers.inspect}"
  @analyzers[subclass.metric] = subclass.new
end
metric() click to toggle source
# File lib/metric_fu/metrics/hotspots/hotspot.rb, line 6
def self.metric
  name.split("::")[-1].split("Hotspot")[0].downcase.to_sym
end

Public Instance Methods

generate_records(_data, _table) click to toggle source

Transforms the data param, if non-nil, into a hash with keys:

'metric',  etc.
and appends the hash to the table param
Has no return value
# File lib/metric_fu/metrics/hotspots/hotspot.rb, line 74
def generate_records(_data, _table)
  not_implemented
end
get_mean(collection) click to toggle source
# File lib/metric_fu/metrics/hotspots/hotspot.rb, line 24
def get_mean(collection)
  MetricFu::HotspotScoringStrategies.average(collection)
end
map(row) click to toggle source
# File lib/metric_fu/metrics/hotspots/hotspot.rb, line 28
def map(row)
  mapping_strategies.fetch(map_strategy) { row.public_send(map_strategy) }
end
map_strategy() click to toggle source
# File lib/metric_fu/metrics/hotspots/hotspot.rb, line 39
def map_strategy
  not_implemented
end
mapping_strategies() click to toggle source
# File lib/metric_fu/metrics/hotspots/hotspot.rb, line 32
def mapping_strategies
  {
    present: 1,
    absent: 0,
  }
end
not_implemented() click to toggle source
# File lib/metric_fu/metrics/hotspots/hotspot.rb, line 83
def not_implemented
  raise "#{caller[0]} not implemented"
end
present_group(_group) click to toggle source

@return [String] description result

# File lib/metric_fu/metrics/hotspots/hotspot.rb, line 79
def present_group(_group)
  not_implemented
end
reduce(scores) click to toggle source
# File lib/metric_fu/metrics/hotspots/hotspot.rb, line 43
def reduce(scores)
  {
    average: MetricFu::HotspotScoringStrategies.average(scores),
    sum: MetricFu::HotspotScoringStrategies.sum(scores),
    absent: 0,
  }.fetch(reduce_strategy) do
    fail "#{reduce_strategy} not a known reduce strategy"
  end
end
reduce_strategy() click to toggle source
# File lib/metric_fu/metrics/hotspots/hotspot.rb, line 53
def reduce_strategy
  not_implemented
end
score(metric_ranking, item) click to toggle source

@return [Integer]

# File lib/metric_fu/metrics/hotspots/hotspot.rb, line 58
def score(metric_ranking, item)
  {
    identity: MetricFu::HotspotScoringStrategies.identity(metric_ranking, item),
    percentile: MetricFu::HotspotScoringStrategies.percentile(metric_ranking, item),
    absent: 0,
  }.fetch(score_strategy) { method(score_strategy).call(metric_ranking, item) }
end
score_strategy() click to toggle source
# File lib/metric_fu/metrics/hotspots/hotspot.rb, line 66
def score_strategy
  not_implemented
end