From: Jean-Philippe Lang Date: Thu, 23 Dec 2010 14:58:52 +0000 (+0000) Subject: Makes Version#start_date return the minimum start_date of its issues. X-Git-Tag: 1.1.0~36 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=df9ea24136059b502d156cb69c8bb2b9b6d952e1;p=redmine.git Makes Version#start_date return the minimum start_date of its issues. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4574 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/models/project.rb b/app/models/project.rb index 355ae3a4c..4af77d1d9 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -454,7 +454,7 @@ class Project < ActiveRecord::Base [ issues.minimum('start_date'), shared_versions.collect(&:effective_date), - shared_versions.collect {|v| v.fixed_issues.minimum('start_date')} + shared_versions.collect(&:start_date) ].flatten.compact.min end diff --git a/app/models/version.rb b/app/models/version.rb index 95e6ad5f6..8b01816a7 100644 --- a/app/models/version.rb +++ b/app/models/version.rb @@ -43,7 +43,7 @@ class Version < ActiveRecord::Base end def start_date - effective_date + @start_date ||= fixed_issues.minimum('start_date') end def due_date @@ -77,8 +77,7 @@ class Version < ActiveRecord::Base def behind_schedule? if completed_pourcent == 100 return false - elsif due_date && fixed_issues.present? && fixed_issues.minimum('start_date') # TODO: should use #start_date but that method is wrong... - start_date = fixed_issues.minimum('start_date') + elsif due_date && start_date done_date = start_date + ((due_date - start_date+1)* completed_pourcent/100).floor return done_date <= Date.today else diff --git a/lib/redmine/helpers/gantt.rb b/lib/redmine/helpers/gantt.rb index af0fc4c72..4954434ce 100644 --- a/lib/redmine/helpers/gantt.rb +++ b/lib/redmine/helpers/gantt.rb @@ -319,7 +319,7 @@ module Redmine options[:zoom] ||= 1 options[:g_width] ||= (self.date_to - self.date_from + 1) * options[:zoom] - coords = coordinates(version.fixed_issues.minimum('start_date'), version.due_date, version.completed_pourcent, options[:zoom]) + coords = coordinates(version.start_date, version.due_date, version.completed_pourcent, options[:zoom]) label = "#{h version } #{h version.completed_pourcent.to_i.to_s}%" label = h("#{version.project} -") + label unless @project && @project == version.project