Project

General

Profile

Patch #39847 ยป cache-journal-attachments.patch

Go MAEDA, 2023-12-14 12:09

View differences:

app/models/journal.rb
142 142
  end
143 143

  
144 144
  def attachments
145
    ids = details.select {|d| d.property == 'attachment' && d.value.present?}.map(&:prop_key)
146
    Attachment.where(id: ids).sort_by {|a| ids.index(a.id.to_s)}
145
    @attachments ||= begin
146
      ids = details.select {|d| d.property == 'attachment' && d.value.present?}.map(&:prop_key)
147
      ids.empty? ? [] : Attachment.where(id: ids).sort_by {|a| ids.index(a.id.to_s)}
148
    end
147 149
  end
148 150

  
149 151
  def visible?(*args)
    (1-1/1)