feat(perf): update query to do a simpler search [CW-2997] (#8763)
Message search would frequently timeout. The reason was that the query would join the conversation too, the new query searches the message table directly Co-authored-by: Sojan <sojan@pepalo.com>
This commit is contained in:
@@ -66,7 +66,7 @@ class Inbox < ApplicationRecord
|
||||
has_many :inbox_members, dependent: :destroy_async
|
||||
has_many :members, through: :inbox_members, source: :user
|
||||
has_many :conversations, dependent: :destroy_async
|
||||
has_many :messages, through: :conversations
|
||||
has_many :messages, dependent: :destroy_async
|
||||
|
||||
has_one :agent_bot_inbox, dependent: :destroy_async
|
||||
has_one :agent_bot, through: :agent_bot_inbox
|
||||
|
||||
@@ -11,7 +11,7 @@ RSpec.describe Imap::ImapMailbox do
|
||||
imap_port: 993, imap_login: 'imap@gmail.com', imap_password: 'password',
|
||||
account: account)
|
||||
end
|
||||
let(:inbox) { create(:inbox, channel: channel, account: account) }
|
||||
let(:inbox) { channel.inbox }
|
||||
let!(:contact) { create(:contact, email: 'email@gmail.com', phone_number: '+919584546666', account: account, identifier: '123') }
|
||||
let(:conversation) { Conversation.where(inbox_id: channel.inbox).last }
|
||||
let(:class_instance) { described_class.new }
|
||||
|
||||
@@ -25,7 +25,7 @@ RSpec.describe Inbox do
|
||||
|
||||
it { is_expected.to have_many(:conversations).dependent(:destroy_async) }
|
||||
|
||||
it { is_expected.to have_many(:messages).through(:conversations) }
|
||||
it { is_expected.to have_many(:messages).dependent(:destroy_async) }
|
||||
|
||||
it { is_expected.to have_one(:agent_bot_inbox) }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user