mirror of
https://github.com/meineerde/redmine.git
synced 2026-01-31 19:47:14 +00:00
Cache the result of Journal#attachments (#39847).
Patch by Go MAEDA (@maeda). git-svn-id: https://svn.redmine.org/redmine/trunk@22581 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
a6509d658b
commit
ccee193f38
@ -142,8 +142,10 @@ class Journal < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def attachments
|
||||
ids = details.select {|d| d.property == 'attachment' && d.value.present?}.map(&:prop_key)
|
||||
Attachment.where(id: ids).sort_by {|a| ids.index(a.id.to_s)}
|
||||
@attachments ||= begin
|
||||
ids = details.select {|d| d.property == 'attachment' && d.value.present?}.map(&:prop_key)
|
||||
ids.empty? ? [] : Attachment.where(id: ids).sort_by {|a| ids.index(a.id.to_s)}
|
||||
end
|
||||
end
|
||||
|
||||
def visible?(*args)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user