mirror of
https://github.com/redmine/redmine.git
synced 2026-01-31 11:50:13 +01:00
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
This commit is contained in:
@@ -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|
|
||||
|
||||
Reference in New Issue
Block a user