active_metric 2.5.3 → 2.5.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -36,6 +36,10 @@ module ActiveMetric
36
36
  title.to_sym
37
37
  end
38
38
 
39
+ def self.approximation
40
+ nil
41
+ end
42
+
39
43
  #TODO Make custom classes namespaced to where they are being defined
40
44
  def self.create_custom_stat(name_of_stat, value_type, default, calculate_block)
41
45
  class_name = name_of_stat.to_s.camelcase
@@ -4,8 +4,9 @@ module ActiveMetric
4
4
  attr_reader :name_of_stat, :klass, :access_name, :options
5
5
 
6
6
  def initialize(name_of_stat, klass, access_name, options)
7
- @name_of_stat, @klass, @access_name, @options = name_of_stat, klass, access_name, options
7
+ @name_of_stat, @klass, @access_name, @options = name_of_stat, klass, access_name, options.clone
8
8
  @options[:axis] ||= 0
9
+ @options[:approximation] ||= klass.approximation
9
10
  end
10
11
 
11
12
  def create_stat
@@ -5,6 +5,10 @@ module ActiveMetric
5
5
  def calculate(measurement)
6
6
  self.value = [self.value, measurement.send(self.property)].min
7
7
  end
8
+
9
+ def self.approximation
10
+ "low"
11
+ end
8
12
  end
9
13
 
10
14
  class Max < Stat
@@ -26,6 +30,10 @@ module ActiveMetric
26
30
  self.value = (self.sum.to_f / self.count)
27
31
  super
28
32
  end
33
+
34
+ def self.approximation
35
+ "average"
36
+ end
29
37
  end
30
38
 
31
39
  class Derivative < Stat
@@ -1,3 +1,3 @@
1
1
  module ActiveMetric
2
- VERSION = "2.5.3"
2
+ VERSION = "2.5.4"
3
3
  end
@@ -87,5 +87,21 @@ module ActiveMetric
87
87
  assert_equal [[2,4],[7,9],[11,13],[14,14]], same_gvm.series_for("max_value").data
88
88
  end
89
89
 
90
+ test "graph view model gets created with approximation as defined in stat then sample class" do
91
+ default_min_approximation = "low"
92
+ default_mean_approximation = "average"
93
+ default_approximation = "high"
94
+ test_sample_defined_approximation = "open"
95
+ report = Report.create
96
+ subject = TestSubject.create :report => report
97
+
98
+ gvm = subject.graph_view_model
99
+
100
+ assert_equal default_min_approximation, gvm.series_for("min_value").approximation
101
+ assert_equal default_mean_approximation, gvm.series_for("mean_value").approximation
102
+ assert_equal default_approximation, gvm.series_for("max_value").approximation
103
+ assert_equal test_sample_defined_approximation, gvm.series_for("standard_deviation_value").approximation
104
+ end
105
+
90
106
  end
91
107
  end
@@ -29,7 +29,7 @@ module ActiveMetric
29
29
 
30
30
  class TestSample < Sample
31
31
  stat :value
32
- stat :value, [:standard_deviation], axis: 1
32
+ stat :value, [:standard_deviation], axis: 1, approximation: "open"
33
33
  stat :value, [:delta], axis: 1
34
34
  stat :value, [:speed], axis: 1
35
35
  stat :value, [:bucket], axis: 2
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_metric
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.3
4
+ version: 2.5.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ authors:
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
- date: 2013-12-16 00:00:00.000000000 Z
17
+ date: 2014-02-07 00:00:00.000000000 Z
18
18
  dependencies: []
19
19
  description: ActiveMetric is a mongo based statistics calculator and persistance layer
20
20
  email: