]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-833: New Web Service to get history of measures (time machine)
authorGodin <mandrikov@gmail.com>
Mon, 13 Dec 2010 22:22:31 +0000 (22:22 +0000)
committerGodin <mandrikov@gmail.com>
Mon, 13 Dec 2010 22:22:31 +0000 (22:22 +0000)
sonar-server/src/main/webapp/WEB-INF/app/controllers/api/timemachine_controller.rb

index 042ba114f81e70a4bd65db14b39794ad161f530c..6ccd0ffa929c12dceca25bf9f5d6a742f7d5170e 100644 (file)
@@ -149,15 +149,22 @@ class Api::TimemachineController < Api::ApiController
 
     xml.snapshots do
       snapshots.each do |snapshot|
-        snapshot_to_xml(xml, snapshot, measures_by_sid[snapshot.id])
+        snapshot_to_xml(xml, snapshot, measures_by_sid[snapshot.id], metric_keys)
       end
     end
   end
 
-  def snapshot_to_xml(xml, snapshot, measures)
+  def snapshot_to_xml(xml, snapshot, measures, metric_keys)
+    values_by_key = {}
+    measures.each do |measure|
+      values_by_key[measure.metric.name] = measure.value.to_f if measure.value
+    end
+
     xml.snapshot do
       xml.date(format_datetime(snapshot.created_at))
-      # TODO measures
+      metric_keys.each do |metric|
+        xml.measure(values_by_key[metric])
+      end
     end
   end