feat: sort conversation on priority (#6943)

* feat: update seed script to include prioritt

* feat: add sort_handler for conversations

* test: sort on priority order

---------

Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
Shivam Mishra
2023-04-25 09:47:47 +05:30
committed by GitHub
parent cf91e9eb58
commit 0bbb28c432
4 changed files with 47 additions and 6 deletions

View File

@@ -21,5 +21,13 @@ module SortHandler
'grouped_conversations.message_type', 'grouped_conversations.created_at ASC'
)
end
def self.sort_on_priority
order(
Arel::Nodes::SqlLiteral.new(
sanitize_sql_for_order('CASE WHEN priority IS NULL THEN 0 ELSE priority END DESC, last_activity_at DESC')
)
)
end
end
end