summaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2010-10-18 11:50:04 +0000
committersimonbrandhof <simon.brandhof@gmail.com>2010-10-18 11:50:04 +0000
commit5a81c5394cca9964e1f11a3acadc9b43fe0e644b (patch)
tree8d78acaed270cd2b85d2b2148763ade96e6005cc /sonar-server
parentff81f007bd43f2f020c24f5fed341a62093de1ad (diff)
downloadsonarqube-5a81c5394cca9964e1f11a3acadc9b43fe0e644b.tar.gz
sonarqube-5a81c5394cca9964e1f11a3acadc9b43fe0e644b.zip
VIEWS-5 TImeMachine only shows first analysis, not latest
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/timemachine_controller.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb8
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/timemachine/index.html.erb1
3 files changed, 6 insertions, 5 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/timemachine_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/timemachine_controller.rb
index 8e2060bd9ca..8292b558c8e 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/timemachine_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/timemachine_controller.rb
@@ -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
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb
index 88cbced598b..942675ecce1 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb
@@ -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
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/timemachine/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/timemachine/index.html.erb
index c6e9c402baf..47d7c0338ba 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/timemachine/index.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/timemachine/index.html.erb
@@ -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];