]> source.dussan.org Git - sonarqube.git/commitdiff
VIEWS-5 TImeMachine only shows first analysis, not latest
authorsimonbrandhof <simon.brandhof@gmail.com>
Mon, 18 Oct 2010 11:50:04 +0000 (11:50 +0000)
committersimonbrandhof <simon.brandhof@gmail.com>
Mon, 18 Oct 2010 11:50:04 +0000 (11:50 +0000)
sonar-server/src/main/webapp/WEB-INF/app/controllers/timemachine_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb
sonar-server/src/main/webapp/WEB-INF/app/views/timemachine/index.html.erb

index 8e2060bd9ca306003d428e03c3d0351065f3bd1a..8292b558c8eee92c2fe47b51a3fed63cf10f09fd 100644 (file)
@@ -39,7 +39,7 @@ class TimemachineController < ApplicationController
          :include => 'events',
          :conditions => {:id => @sids, :project_id => @project.id}, :order => 'snapshots.created_at ASC')
     else
-      @snapshots=Snapshot.for_timemachine_matrix(@project.id)
+      @snapshots=Snapshot.for_timemachine_matrix(@project)
       @sids = @snapshots.collect{|s| s.id}.uniq
     end
 
index 88cbced598b21f1e81d843e603b345849376f80a..942675ecce1a39dc7005f5f5877d5d2e5250cbfe 100644 (file)
@@ -48,15 +48,17 @@ class Snapshot < ActiveRecord::Base
         true, Project::SCOPE_SET, Project::QUALIFIER_PROJECT, Project::SCOPE_SET, Project::QUALIFIER_PROJECT])
   end
   
-  def self.for_timemachine_matrix(resource_id)
-    snapshots=Snapshot.find(:all, :conditions => ["snapshots.project_id=? AND events.snapshot_id=snapshots.id AND snapshots.status=?", resource_id, STATUS_PROCESSED],
+  def self.for_timemachine_matrix(resource)
+    snapshots=Snapshot.find(:all, :conditions => ["snapshots.project_id=? AND events.snapshot_id=snapshots.id AND snapshots.status=?", resource.id, STATUS_PROCESSED],
        :include => 'events',
        :order => 'snapshots.created_at ASC')
 
+    snapshots<<resource.last_snapshot if snapshots.empty?
+    
     snapshots=snapshots[-5,5] if snapshots.size>=5
 
     snapshots.insert(0, Snapshot.find(:first,
-         :conditions => ["project_id = :project_id AND status IN (:status)", {:project_id => resource_id, :status => STATUS_PROCESSED}],
+         :conditions => ["project_id = :project_id AND status IN (:status)", {:project_id => resource.id, :status => STATUS_PROCESSED}],
          :include => 'project', :order => 'snapshots.created_at ASC', :limit => 1))
     snapshots.compact.uniq
   end
index c6e9c402baf592d4880ab93ce2fc69636544b339..47d7c0338ba4519880f121aafdfcadd7ba05212e 100644 (file)
@@ -6,7 +6,6 @@
 <script type="text/javascript">
     var selectedSnapshots = new Array();
 
-
     function selectTimeMachineSnapshot(id) {
       if (id != null && id != '' && selectedSnapshots.indexOf(id) == -1) {
         var snapshotDate = snapshots[id];