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

index cf34d238d0d0bf0dddc89684ca451f35d0f3731b..d69372155d7983e45c76be6c6d5c9295906f9899 100644 (file)
@@ -20,7 +20,6 @@
 class Api::TimemachineController < Api::ApiController
   MAX_IN_ELEMENTS=990
   #
-  # TODO date range
   # GET /api/timemachine
   #
   def index
@@ -28,6 +27,8 @@ class Api::TimemachineController < Api::ApiController
       resource_id = params[:resource]
       metric_keys = params[:metrics].split(',')
       metrics = Metric.by_keys(metric_keys)
+      first_date = parse_datetime(params[:first_date])
+      last_date = parse_datetime(params[:last_date])
 
       @resource=Project.by_key(resource_id)
       if @resource.nil?
@@ -35,7 +36,8 @@ class Api::TimemachineController < Api::ApiController
       end
 
       snapshots = Snapshot.find(:all,
-      :conditions => {:project_id => @resource.id, :status => Snapshot::STATUS_PROCESSED},
+      :conditions => ['created_at>=? AND created_at<=? AND project_id=? AND status=?',
+        first_date, last_date, @resource.id, Snapshot::STATUS_PROCESSED],
       :order => 'created_at')
 
       # Oracle limitation : no more than 1000 elements in IN clause