Defect #24457 » done_ratio_for_version.diff
| app/models/version.rb | ||
|---|---|---|
| 274 | 274 |
# Used to weight unestimated issues in progress calculation |
| 275 | 275 |
def estimated_average |
| 276 | 276 |
if @estimated_average.nil? |
| 277 |
average = fixed_issues.average(:estimated_hours).to_f |
|
| 278 |
if average == 0 |
|
| 279 |
average = 1 |
|
| 277 |
issues_with_total_estimated_hours = fixed_issues.select {|c| c.total_estimated_hours.to_f > 0.0}
|
|
| 278 |
if issues_with_total_estimated_hours.any? |
|
| 279 |
average = issues_with_total_estimated_hours.map(&:total_estimated_hours).sum.to_f / issues_with_total_estimated_hours.count |
|
| 280 |
else |
|
| 281 |
average = 1.0 |
|
| 280 | 282 |
end |
| 281 | 283 |
@estimated_average = average |
| 282 | 284 |
end |
| ... | ... | |
| 294 | 296 |
@issues_progress[open] ||= begin |
| 295 | 297 |
progress = 0 |
| 296 | 298 |
if issues_count > 0 |
| 297 |
ratio = open ? 'done_ratio' : 100 |
|
| 299 |
done = fixed_issues.open(open).map {|c|
|
|
| 300 |
estimated = c.total_estimated_hours.to_f |
|
| 301 |
estimated = estimated_average unless estimated > 0.0 |
|
| 302 |
ratio = c.closed? ? 100 : (c.done_ratio || 0) |
|
| 303 |
estimated * ratio |
|
| 304 |
}.sum |
|
| 298 | 305 | |
| 299 |
done = fixed_issues.open(open).sum("COALESCE(estimated_hours, #{estimated_average}) * #{ratio}").to_f
|
|
| 300 | 306 |
progress = done / (estimated_average * issues_count) |
| 301 | 307 |
end |
| 302 | 308 |
progress |