[Feature] Change conversation ordering (#640)

* Update conversation's updated_at when a message is created/saved
* changed teh ordering of conversation to be based on `updated_at` rather than `created_at`
This commit is contained in:
Sony Mathew
2020-03-24 23:34:22 +05:30
committed by GitHub
parent 2eac97c705
commit 209e0a0fb4
2 changed files with 2 additions and 2 deletions

View File

@@ -36,7 +36,7 @@ class Conversation < ApplicationRecord
enum status: { open: 0, resolved: 1, bot: 2 }
scope :latest, -> { order(created_at: :desc) }
scope :latest, -> { order(updated_at: :desc) }
scope :unassigned, -> { where(assignee_id: nil) }
scope :assigned_to, ->(agent) { where(assignee_id: agent.id) }

View File

@@ -51,7 +51,7 @@ class Message < ApplicationRecord
belongs_to :account
belongs_to :inbox
belongs_to :conversation
belongs_to :conversation, touch: true
belongs_to :user, required: false
belongs_to :contact, required: false