From 6662f3b868d927eb838202b5fcc1e8150dff346f Mon Sep 17 00:00:00 2001 From: Godin Date: Mon, 13 Dec 2010 22:22:31 +0000 Subject: [PATCH] SONAR-833: New Web Service to get history of measures (time machine) --- .../app/controllers/api/timemachine_controller.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/timemachine_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/timemachine_controller.rb index 042ba114f81..6ccd0ffa929 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/timemachine_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/timemachine_controller.rb @@ -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 -- 2.39.5