From 5a81c5394cca9964e1f11a3acadc9b43fe0e644b Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Mon, 18 Oct 2010 11:50:04 +0000 Subject: [PATCH] VIEWS-5 TImeMachine only shows first analysis, not latest --- .../WEB-INF/app/controllers/timemachine_controller.rb | 2 +- .../src/main/webapp/WEB-INF/app/models/snapshot.rb | 8 +++++--- .../webapp/WEB-INF/app/views/timemachine/index.html.erb | 1 - 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<=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 @@