fix: Limit count query to return only 10 values (#7704)

This commit is contained in:
Pranav Raj S
2023-08-10 19:30:02 -07:00
committed by GitHub
parent 04287a0924
commit 1cac2e86c3
3 changed files with 4 additions and 6 deletions

View File

@@ -19,10 +19,8 @@ end
json.id conversation.display_id
if conversation.messages.first.blank?
json.messages []
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([{ attachments: [{ file_attachment: [:blob] }] }]).last(10).map(&:push_event_data)
json.messages [conversation.messages.includes([{ attachments: [{ file_attachment: [:blob] }] }]).last.try(:push_event_data)]
end
json.account_id conversation.account_id