]> source.dussan.org Git - redmine.git/commitdiff
Optimize `Issue#relations` method to improve performance by fetching both `relations_...
authorGo MAEDA <maeda@farend.jp>
Thu, 28 Dec 2023 00:10:34 +0000 (00:10 +0000)
committerGo MAEDA <maeda@farend.jp>
Thu, 28 Dec 2023 00:10:34 +0000 (00:10 +0000)
Patch by Go MAEDA (@maeda).

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

app/models/issue.rb

index 120bddd9b3a7bfc57e47c64e417b1b1836fd3d25..17802d22774a3ae75b7c87136ca6b15cf2560bfc 100644 (file)
@@ -1166,7 +1166,10 @@ class Issue < ActiveRecord::Base
   end
 
   def relations
-    @relations ||= IssueRelation::Relations.new(self, (relations_from + relations_to).sort)
+    @relations ||= IssueRelation::Relations.new(
+      self,
+      IssueRelation.where('issue_from_id = ? OR issue_to_id = ?', id, id).sort
+    )
   end
 
   def last_updated_by