Use :joins instead of :include in calculations.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8382 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
f8cb06bff2
commit
b20598d755
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue