Browse Source

VIEWS-5 TImeMachine only shows first analysis, not latest

tags/2.6
simonbrandhof 13 years ago
parent
commit
5a81c5394c

+ 1
- 1
sonar-server/src/main/webapp/WEB-INF/app/controllers/timemachine_controller.rb View 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


+ 5
- 3
sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb View 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

+ 0
- 1
sonar-server/src/main/webapp/WEB-INF/app/views/timemachine/index.html.erb View 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];

Loading…
Cancel
Save