fix: last incoming message sort (#4972)

This commit is contained in:
Tejaswini Chile
2022-07-06 00:37:43 +05:30
committed by GitHub
parent ac2adfbd57
commit b86638faac
5 changed files with 56 additions and 48 deletions

View File

@@ -11,14 +11,14 @@ module SortHandler
end
def self.last_messaged_conversations
Message.except(:order).select('DISTINCT ON (conversation_id) *').order('conversation_id, created_at DESC')
Message.except(:order).select(
'DISTINCT ON (conversation_id) conversation_id, id, created_at, message_type'
).order('conversation_id, created_at DESC')
end
def self.sort_on_last_user_message_at
where(
'grouped_conversations.message_type = 0'
).order(
'grouped_conversations.created_at ASC'
order(
'grouped_conversations.message_type', 'grouped_conversations.created_at ASC'
)
end
end