]> source.dussan.org Git - redmine.git/commitdiff
Get the list of new issue watchers using single query and limit the results to 20...
authorGo MAEDA <maeda@farend.jp>
Sat, 25 Apr 2020 07:57:46 +0000 (07:57 +0000)
committerGo MAEDA <maeda@farend.jp>
Sat, 25 Apr 2020 07:57:46 +0000 (07:57 +0000)
Patch by Marius BALTEANU.

git-svn-id: http://svn.redmine.org/redmine/trunk@19723 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/issues_helper.rb

index 792c5a5082292a0bc75d0e892493c4303863fc75..c43646174172cdf178da29455629b0e158e0dc61 100644 (file)
@@ -365,13 +365,11 @@ module IssuesHelper
   # on the new issue form
   def users_for_new_issue_watchers(issue)
     users = issue.watcher_users.select{|u| u.status == User::STATUS_ACTIVE}
-    project = issue.project
-    scope_users = project.users
-    scope_groups = project.principals.merge(Group.givable)
-    if scope_users.count + scope_groups.count <= 20
-      users = (users + scope_users.sort + scope_groups.sort).uniq
+    project_principals = issue.project.principals.where(:users => {:type => ['User', 'Group']}).limit(21)
+    if project_principals.size <= 20
+      users += project_principals.sort
     end
-    users
+    users.uniq
   end
 
   def email_issue_attributes(issue, user, html)