Class: MetricFu::Hotspot

Inherits:
Object
  • Object
show all
Defined in:
lib/metric_fu/metrics/hotspots/hotspot.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.analyzer_for_metric(metric) ⇒ Object



13
14
15
16
17
18
# 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

.analyzersObject



10
11
12
# File 'lib/metric_fu/metrics/hotspots/hotspot.rb', line 10

def self.analyzers
  @analyzers.values
end

.metricObject



6
7
8
# File 'lib/metric_fu/metrics/hotspots/hotspot.rb', line 6

def self.metric
  name.split("::")[-1].split("Hotspot")[0].downcase.to_sym
end

Instance Method Details

#generate_records(_data, _table) ⇒ Object

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


74
75
76
# File 'lib/metric_fu/metrics/hotspots/hotspot.rb', line 74

def generate_records(_data, _table)
  not_implemented
end

#get_mean(collection) ⇒ Object



24
25
26
# File 'lib/metric_fu/metrics/hotspots/hotspot.rb', line 24

def get_mean(collection)
  MetricFu::HotspotScoringStrategies.average(collection)
end

#map(row) ⇒ Object



28
29
30
# 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_strategyObject



39
40
41
# File 'lib/metric_fu/metrics/hotspots/hotspot.rb', line 39

def map_strategy
  not_implemented
end

#mapping_strategiesObject



32
33
34
35
36
37
# File 'lib/metric_fu/metrics/hotspots/hotspot.rb', line 32

def mapping_strategies
  {
    present: 1,
    absent: 0,
  }
end

#not_implementedObject



83
84
85
# File 'lib/metric_fu/metrics/hotspots/hotspot.rb', line 83

def not_implemented
  raise "#{caller[0]} not implemented"
end

#present_group(_group) ⇒ String

Returns description result.

Returns:

  • (String)

    description result



79
80
81
# File 'lib/metric_fu/metrics/hotspots/hotspot.rb', line 79

def present_group(_group)
  not_implemented
end

#reduce(scores) ⇒ Object



43
44
45
46
47
48
49
50
51
# 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_strategyObject



53
54
55
# File 'lib/metric_fu/metrics/hotspots/hotspot.rb', line 53

def reduce_strategy
  not_implemented
end

#score(metric_ranking, item) ⇒ Integer

Returns:

  • (Integer)


58
59
60
61
62
63
64
# 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_strategyObject



66
67
68
# File 'lib/metric_fu/metrics/hotspots/hotspot.rb', line 66

def score_strategy
  not_implemented
end