37151-v2.patch

Go MAEDA, 2022-05-26 16:28

Download (1.37 KB)

View differences:

app/models/issue.rb
1838 1838
          if children.any?
1839 1839
            child_with_total_estimated_hours = children.select {|c| c.total_estimated_hours.to_f > 0.0}
1840 1840
            if child_with_total_estimated_hours.any?
1841
              average =
1842
                child_with_total_estimated_hours.sum(&:total_estimated_hours).to_d /
1843
                  child_with_total_estimated_hours.count
1841
              average = Rational(
1842
                child_with_total_estimated_hours.sum(&:total_estimated_hours).to_d,
1843
                child_with_total_estimated_hours.count
1844
              )
1844 1845
            else
1845
              average = BigDecimal('1.0')
1846
              average = Rational(1)
1846 1847
            end
1847 1848
            done = children.sum do |c|
1848
              estimated = (c.total_estimated_hours || 0.0).to_d
1849
              estimated = Rational(c.total_estimated_hours&.to_d || 0)
1849 1850
              estimated = average unless estimated > 0.0
1850 1851
              ratio = c.closed? ? 100 : (c.done_ratio || 0)
1851 1852
              estimated * ratio
1852 1853
            end
1853
            progress = done / (average * children.count)
1854
            progress = Rational(done, average * children.count)
1854 1855
            p.done_ratio = progress.floor
1855 1856
          end
1856 1857
        end