From: Marius Balteanu Date: Thu, 2 May 2024 21:35:16 +0000 (+0000) Subject: Fixes RuboCop offense Performance/Sum (#24457, #4682). X-Git-Tag: 6.0.0~358 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1a96ee225dd4ebc58848c3459804a4254837a01f;p=redmine.git Fixes RuboCop offense Performance/Sum (#24457, #4682). git-svn-id: https://svn.redmine.org/redmine/trunk@22805 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/models/version.rb b/app/models/version.rb index e1525f9a0..ec1a9f77b 100644 --- a/app/models/version.rb +++ b/app/models/version.rb @@ -80,7 +80,7 @@ module FixedIssuesExtension if @estimated_average.nil? 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 + average = issues_with_total_estimated_hours.sum(&:total_estimated_hours).to_f / issues_with_total_estimated_hours.count else average = 1.0 end @@ -100,12 +100,12 @@ module FixedIssuesExtension @issues_progress[open] ||= begin progress = 0 if count > 0 - done = open(open).map {|c| + done = open(open).sum do |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 + end progress = done / (estimated_average * count) end progress