diff options
author | Go MAEDA <maeda@farend.jp> | 2025-01-18 05:36:19 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2025-01-18 05:36:19 +0000 |
commit | cf4a72d3f52fbf9186f226b5e8a05fca22351d58 (patch) | |
tree | 15256105cd50594490880608eac08aedebd5d5fd | |
parent | 3713245bc61ac93e5d92f152eba8d8b3d00af3a2 (diff) | |
download | redmine-cf4a72d3f52fbf9186f226b5e8a05fca22351d58.tar.gz redmine-cf4a72d3f52fbf9186f226b5e8a05fca22351d58.zip |
Optimize `journalized` method to use preloaded Issue association for better Activity view performance (#42077).
Patch by Go MAEDA (user:maeda).
git-svn-id: https://svn.redmine.org/redmine/trunk@23446 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/models/journal.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/journal.rb b/app/models/journal.rb index 446eac7a6..e83905a3c 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -104,6 +104,15 @@ class Journal < ApplicationRecord (details.empty? && notes.blank?) ? false : super() end + def journalized + if journalized_type == 'Issue' && association(:issue).loaded? + # Avoid extra query by using preloaded association + issue + else + super + end + end + # Returns journal details that are visible to user def visible_details(user=User.current) details.select do |detail| |