]> source.dussan.org Git - redmine.git/commitdiff
Prevents useless COUNT queries.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 26 Oct 2014 22:20:10 +0000 (22:20 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 26 Oct 2014 22:20:10 +0000 (22:20 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@13514 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/issue.rb

index 6d5d27631f5e109ad7b942467027b0a8a237683e..31b2d69f1b92a4960ce5e3e42bcf553f5c182bba 100644 (file)
@@ -541,11 +541,11 @@ class Issue < ActiveRecord::Base
     return @workflow_rule_by_attribute if @workflow_rule_by_attribute && user.nil?
 
     user_real = user || User.current
-    roles = user_real.admin ? Role.all : user_real.roles_for_project(project)
+    roles = user_real.admin ? Role.all.to_a : user_real.roles_for_project(project)
     return {} if roles.empty?
 
     result = {}
-    workflow_permissions = WorkflowPermission.where(:tracker_id => tracker_id, :old_status_id => status_id, :role_id => roles.map(&:id))
+    workflow_permissions = WorkflowPermission.where(:tracker_id => tracker_id, :old_status_id => status_id, :role_id => roles.map(&:id)).to_a
     if workflow_permissions.any?
       workflow_rules = workflow_permissions.inject({}) do |h, wp|
         h[wp.field_name] ||= []