Patch #34399 » performance-sum.diff
app/models/issue.rb (作業コピー) | ||
---|---|---|
1743 | 1743 |
if children.any? |
1744 | 1744 |
child_with_total_estimated_hours = children.select {|c| c.total_estimated_hours.to_f > 0.0} |
1745 | 1745 |
if child_with_total_estimated_hours.any? |
1746 |
average = child_with_total_estimated_hours.map(&:total_estimated_hours).sum.to_d / child_with_total_estimated_hours.count
|
|
1746 |
average = child_with_total_estimated_hours.sum(&:total_estimated_hours).to_d / child_with_total_estimated_hours.count
|
|
1747 | 1747 |
else |
1748 | 1748 |
average = 1.0.to_d |
1749 | 1749 |
end |
1750 |
done = children.map do |c|
|
|
1750 |
done = children.sum do |c|
|
|
1751 | 1751 |
estimated = (c.total_estimated_hours || 0.0).to_d |
1752 | 1752 |
estimated = average unless estimated > 0.0 |
1753 | 1753 |
ratio = c.closed? ? 100 : (c.done_ratio || 0) |
1754 | 1754 |
estimated * ratio |
1755 |
end.sum
|
|
1755 |
end |
|
1756 | 1756 |
progress = done / (average * children.count) |
1757 | 1757 |
p.done_ratio = progress.floor |
1758 | 1758 |
end |
app/models/project.rb (作業コピー) | ||
---|---|---|
677 | 677 |
# progress on it's versions. |
678 | 678 |
def completed_percent(options={:include_subprojects => false}) |
679 | 679 |
if options.delete(:include_subprojects) |
680 |
total = self_and_descendants.collect(&:completed_percent).sum
|
|
680 |
total = self_and_descendants.sum(&:completed_percent)
|
|
681 | 681 | |
682 | 682 |
total / self_and_descendants.count |
683 | 683 |
else |
684 | 684 |
if versions.count > 0 |
685 |
total = versions.collect(&:completed_percent).sum
|
|
685 |
total = versions.sum(&:completed_percent)
|
|
686 | 686 | |
687 | 687 |
total / versions.count |
688 | 688 |
else |