Revert "fix: classify bot-owned conversations as assigned"

This reverts commit 365935c440.
This commit is contained in:
Sojan Jose
2026-07-20 18:16:01 -07:00
parent 365935c440
commit 26b8650f92
3 changed files with 11 additions and 19 deletions
+1 -1
View File
@@ -189,7 +189,7 @@ class ConversationFinder
counts = @conversations.unscope(:order).pick(
Arel.sql("COUNT(*) FILTER (WHERE assignee_id = #{current_user.id})"),
Arel.sql('COUNT(*) FILTER (WHERE assignee_id IS NULL AND assignee_agent_bot_id IS NULL)'),
Arel.sql('COUNT(*) FILTER (WHERE assignee_id IS NULL)'),
Arel.sql('COUNT(*)')
)
counts || [0, 0, 0]
+2 -2
View File
@@ -75,8 +75,8 @@ class Conversation < ApplicationRecord
enum status: { open: 0, resolved: 1, pending: 2, snoozed: 3 }
enum priority: { low: 0, medium: 1, high: 2, urgent: 3 }
scope :unassigned, -> { where(assignee_id: nil, assignee_agent_bot_id: nil) }
scope :assigned, -> { where.not(assignee_id: nil).or(where.not(assignee_agent_bot_id: nil)) }
scope :unassigned, -> { where(assignee_id: nil) }
scope :assigned, -> { where.not(assignee_id: nil) }
scope :assigned_to, ->(agent) { where(assignee_id: agent.id) }
scope :sort_on_unread, lambda { |_direction|
order(unread_messages_count_arel.desc).sort_on_last_activity_at('desc')
+8 -16
View File
@@ -10,8 +10,6 @@ describe ConversationFinder do
let!(:inbox) { create(:inbox, account: account, enable_auto_assignment: false) }
let!(:contact_inbox) { create(:contact_inbox, inbox: inbox, source_id: 'testing_source_id') }
let!(:restricted_inbox) { create(:inbox, account: account) }
let!(:agent_bot) { create(:agent_bot, account: account) }
let!(:bot_owned_conversation) { create(:conversation, account: account, inbox: inbox, assignee_agent_bot: agent_bot) }
before do
create(:inbox_member, user: user_1, inbox: inbox)
@@ -76,7 +74,7 @@ describe ConversationFinder do
it 'filter conversations by assignee type all' do
result = conversation_finder.perform
expect(result[:conversations].length).to be 5
expect(result[:conversations].length).to be 4
end
end
@@ -85,10 +83,7 @@ describe ConversationFinder do
it 'filter conversations by assignee type unassigned' do
result = conversation_finder.perform
conversation_ids = result[:conversations].map(&:id)
expect(result[:conversations].length).to be 1
expect(conversation_ids).not_to include(bot_owned_conversation.id)
end
end
@@ -97,7 +92,7 @@ describe ConversationFinder do
it 'returns all conversations' do
result = conversation_finder.perform
expect(result[:conversations].length).to be 6
expect(result[:conversations].length).to be 5
end
end
@@ -167,19 +162,16 @@ describe ConversationFinder do
it 'filter conversations by assignee type assigned' do
result = conversation_finder.perform
conversation_ids = result[:conversations].map(&:id)
expect(result[:conversations].length).to be 4
expect(conversation_ids).to include(bot_owned_conversation.id)
expect(result[:conversations].length).to be 3
end
it 'returns the correct meta' do
result = conversation_finder.perform
expect(result[:count]).to eq({
mine_count: 2,
assigned_count: 4,
assigned_count: 3,
unassigned_count: 1,
all_count: 5
all_count: 4
})
end
end
@@ -221,7 +213,7 @@ describe ConversationFinder do
it 'returns conversations with any source' do
result = conversation_finder.perform
expect(result[:conversations].length).to be 5
expect(result[:conversations].length).to be 4
end
end
@@ -272,9 +264,9 @@ describe ConversationFinder do
result = conversation_finder.perform_meta_only
expect(result[:count]).to eq({
mine_count: 2,
assigned_count: 4,
assigned_count: 3,
unassigned_count: 1,
all_count: 5
all_count: 4
})
end