Defect #24457 » 0001-Version-progress-should.patch
| app/models/version.rb | ||
|---|---|---|
| 78 | 78 | 
    # Used to weight unestimated issues in progress calculation  | 
| 79 | 79 | 
    def estimated_average  | 
| 80 | 80 | 
    if @estimated_average.nil?  | 
| 81 | 
    average = average(:estimated_hours).to_f  | 
|
| 82 | 
    if average == 0  | 
|
| 83 | 
    average = 1  | 
|
| 81 | 
          issues_with_total_estimated_hours = select {|c| c.total_estimated_hours.to_f > 0.0}
   | 
|
| 82 | 
    if issues_with_total_estimated_hours.any?  | 
|
| 83 | 
    average = issues_with_total_estimated_hours.map(&:total_estimated_hours).sum.to_f / issues_with_total_estimated_hours.count  | 
|
| 84 | 
    else  | 
|
| 85 | 
    average = 1.0  | 
|
| 84 | 86 | 
    end  | 
| 85 | 87 | 
    @estimated_average = average  | 
| 86 | 88 | 
    end  | 
| ... | ... | |
| 98 | 100 | 
    @issues_progress[open] ||= begin  | 
| 99 | 101 | 
    progress = 0  | 
| 100 | 102 | 
    if count > 0  | 
| 101 | 
    ratio = open ? 'done_ratio' : 100  | 
|
| 102 | ||
| 103 | 
            done = open(open).sum("COALESCE(estimated_hours, #{estimated_average}) * #{ratio}").to_f
   | 
|
| 103 | 
            done = open(open).map {|c|
   | 
|
| 104 | 
    estimated = c.total_estimated_hours.to_f  | 
|
| 105 | 
    estimated = estimated_average unless estimated > 0.0  | 
|
| 106 | 
    ratio = c.closed? ? 100 : (c.done_ratio || 0)  | 
|
| 107 | 
    estimated * ratio  | 
|
| 108 | 
    }.sum  | 
|
| 104 | 109 | 
    progress = done / (estimated_average * count)  | 
| 105 | 110 | 
    end  | 
| 106 | 111 | 
    progress  | 
| test/unit/version_test.rb | ||
|---|---|---|
| 116 | 116 | 
    assert_progress_equal (100.0)/3, v.closed_percent  | 
| 117 | 117 | 
    end  | 
| 118 | 118 | |
| 119 | 
    def test_progress_should_consider_closed_issues_with_0h_estimated_as_completed  | 
|
| 120 | 
    project = Project.find(1)  | 
|
| 121 | 
    closed = IssueStatus.where(:is_closed => true).first  | 
|
| 122 | 
    v = Version.create!(:project => project, :name => 'Progress')  | 
|
| 123 | 
    add_issue(v, :done_ratio => 100, :estimated_hours => 0)  | 
|
| 124 | 
    add_issue(v, :done_ratio => 100, :estimated_hours => 0, :status => closed)  | 
|
| 125 | 
    assert_progress_equal 100, v.completed_percent  | 
|
| 126 | 
    assert_progress_equal 50, v.closed_percent  | 
|
| 127 | 
    end  | 
|
| 128 | ||
| 119 | 129 | 
    def test_progress_should_consider_estimated_hours_to_weight_issues  | 
| 120 | 130 | 
    project = Project.find(1)  | 
| 121 | 131 | 
    v = Version.create!(:project => project, :name => 'Progress')  | 
- « Previous
 - 1
 - 2
 - Next »