summaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorMarius Balteanu <marius.balteanu@zitec.com>2024-05-02 20:58:03 +0000
committerMarius Balteanu <marius.balteanu@zitec.com>2024-05-02 20:58:03 +0000
commitcd8d4fe444328925a71b9018dac8b6194801d547 (patch)
tree51988a091862eb952445eaa03f9a20e69df26805 /app/models
parent3433731585b6126208cd855b46115d18d249fb1f (diff)
downloadredmine-cd8d4fe444328925a71b9018dac8b6194801d547.tar.gz
redmine-cd8d4fe444328925a71b9018dac8b6194801d547.zip
Progress of version should be calculated the same way as parent tasks (#24457, #4682).
git-svn-id: https://svn.redmine.org/redmine/trunk@22803 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r--app/models/version.rb17
1 files changed, 11 insertions, 6 deletions
diff --git a/app/models/version.rb b/app/models/version.rb
index 17e1128e4..e1525f9a0 100644
--- a/app/models/version.rb
+++ b/app/models/version.rb
@@ -78,9 +78,11 @@ module FixedIssuesExtension
# Used to weight unestimated issues in progress calculation
def estimated_average
if @estimated_average.nil?
- average = average(:estimated_hours).to_f
- if average == 0
- average = 1
+ issues_with_total_estimated_hours = select {|c| c.total_estimated_hours.to_f > 0.0}
+ if issues_with_total_estimated_hours.any?
+ average = issues_with_total_estimated_hours.map(&:total_estimated_hours).sum.to_f / issues_with_total_estimated_hours.count
+ else
+ average = 1.0
end
@estimated_average = average
end
@@ -98,9 +100,12 @@ module FixedIssuesExtension
@issues_progress[open] ||= begin
progress = 0
if count > 0
- ratio = open ? 'done_ratio' : 100
-
- done = open(open).sum("COALESCE(estimated_hours, #{estimated_average}) * #{ratio}").to_f
+ done = open(open).map {|c|
+ estimated = c.total_estimated_hours.to_f
+ estimated = estimated_average unless estimated > 0.0
+ ratio = c.closed? ? 100 : (c.done_ratio || 0)
+ estimated * ratio
+ }.sum
progress = done / (estimated_average * count)
end
progress