From b20598d755c511a9113d7554d5bda790fa64ea8a Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Mon, 26 Dec 2011 12:07:07 +0000 Subject: [PATCH] Use :joins instead of :include in calculations. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8382 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/issue.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/issue.rb b/app/models/issue.rb index c46d035eb..4c7323c6d 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -817,7 +817,7 @@ class Issue < ActiveRecord::Base def recalculate_attributes_for(issue_id) if issue_id && p = Issue.find_by_id(issue_id) # priority = highest priority of children - if priority_position = p.children.maximum("#{IssuePriority.table_name}.position", :include => :priority) + if priority_position = p.children.maximum("#{IssuePriority.table_name}.position", :joins => :priority) p.priority = IssuePriority.find_by_position(priority_position) end @@ -836,7 +836,7 @@ class Issue < ActiveRecord::Base if average == 0 average = 1 end - done = p.leaves.sum("COALESCE(estimated_hours, #{average}) * (CASE WHEN is_closed = #{connection.quoted_true} THEN 100 ELSE COALESCE(done_ratio, 0) END)", :include => :status).to_f + done = p.leaves.sum("COALESCE(estimated_hours, #{average}) * (CASE WHEN is_closed = #{connection.quoted_true} THEN 100 ELSE COALESCE(done_ratio, 0) END)", :joins => :status).to_f progress = done / (average * leaves_count) p.done_ratio = progress.round end