Commit 78623c06f702c5c49513b1c49cedf9622d56e37a
Committed by
Alessandro Palmeira
1 parent
ca0e5487
Exists in
master
and in
28 other branches
[Mezuro] Prepared metric_result for agreggated_value
Showing
2 changed files
with
9 additions
and
3 deletions
Show diff stats
plugins/mezuro/lib/kalibro/metric_configuration_snapshot.rb
| @@ -26,7 +26,6 @@ class Kalibro::MetricConfigurationSnapshot < Kalibro::Model | @@ -26,7 +26,6 @@ class Kalibro::MetricConfigurationSnapshot < Kalibro::Model | ||
| 26 | 26 | ||
| 27 | def to_hash | 27 | def to_hash |
| 28 | hash = super | 28 | hash = super |
| 29 | - puts hash | ||
| 30 | hash[:attributes!][:range] = {'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', | 29 | hash[:attributes!][:range] = {'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', |
| 31 | 'xsi:type' => 'kalibro:rangeSnapshotXml' } | 30 | 'xsi:type' => 'kalibro:rangeSnapshotXml' } |
| 32 | hash | 31 | hash |
plugins/mezuro/lib/kalibro/metric_result.rb
| @@ -2,8 +2,15 @@ class Kalibro::MetricResult < Kalibro::Model | @@ -2,8 +2,15 @@ class Kalibro::MetricResult < Kalibro::Model | ||
| 2 | 2 | ||
| 3 | attr_accessor :id, :configuration, :value, :error | 3 | attr_accessor :id, :configuration, :value, :error |
| 4 | 4 | ||
| 5 | - def value=(value) | ||
| 6 | - @value = value.to_f | 5 | + def initialize(attributes={}) |
| 6 | + value = attributes[:value] | ||
| 7 | + value == "NaN" ? @value = attributes[:agreggated_value] : @value = value.to_f | ||
| 8 | + attributes.each do |field, value| | ||
| 9 | + if field!="value" and field!="agreggated_value" and self.class.is_valid?(field) | ||
| 10 | + send("#{field}=", value) | ||
| 11 | + end | ||
| 12 | + end | ||
| 13 | + @errors = [] | ||
| 7 | end | 14 | end |
| 8 | 15 | ||
| 9 | def configuration=(value) | 16 | def configuration=(value) |