]> source.dussan.org Git - sonarqube.git/commitdiff
manual_measures - fix mapping in ruby code
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Wed, 11 Feb 2015 17:14:10 +0000 (18:14 +0100)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Wed, 11 Feb 2015 17:30:55 +0000 (18:30 +0100)
server/sonar-web/src/main/webapp/WEB-INF/app/models/manual_measure.rb

index a292be623ab5c1000102e4f6190c9a419568d0f0..d115fb1ebfabc1b64306cf163993d92f1ed44988 100644 (file)
@@ -26,6 +26,19 @@ class ManualMeasure < ActiveRecord::Base
   validates_length_of :description, :maximum => 4000, :allow_nil => true, :allow_blank => true
   validate :validate_metric, :validate_value
 
+  def created_at
+    long_to_date(:created_at)
+  end
+  
+  def updated_at
+    long_to_date(:updated_at)
+  end
+  
+  def long_to_date(attribute)
+    date_in_long = read_attribute(attribute)
+    Time.at(date_in_long/1000) if date_in_long
+  end
+  
   def metric
     @metric ||=
         begin
@@ -61,7 +74,7 @@ class ManualMeasure < ActiveRecord::Base
     if snapshot.nil?
       snapshot=resource.last_snapshot
     end
-    snapshot && updated_at && snapshot.created_at<Time.at(updated_at/1000)
+    snapshot && updated_at && snapshot.created_at<updated_at
   end
 
   def formatted_value