feat(perf): update query to reduce N+1 impact [CW-1926] (#7228)
* feat: update query to reduce N+1 impact * feat: remove channel eager loading fixes the error: ActiveRecord::EagerLoadPolymorphicError Exception: Cannot eagerly load the polymorphic association :channel * test: fix search test * chore: revert change
This commit is contained in:
@@ -22,7 +22,7 @@ if conversation.messages.first.blank?
|
||||
elsif conversation.unread_incoming_messages.count.zero?
|
||||
json.messages [conversation.messages.includes([{ attachments: [{ file_attachment: [:blob] }] }]).last.try(:push_event_data)]
|
||||
else
|
||||
json.messages conversation.unread_messages.includes([:user, { attachments: [{ file_attachment: [:blob] }] }]).last(10).map(&:push_event_data)
|
||||
json.messages conversation.unread_messages.includes([{ attachments: [{ file_attachment: [:blob] }] }]).last(10).map(&:push_event_data)
|
||||
end
|
||||
|
||||
json.account_id conversation.account_id
|
||||
|
||||
Reference in New Issue
Block a user