feat: Enable Capacity Config UI (#5164)

- Enables Capacity Config in UI
- Rewrite auto assignment Logic to consider only online agents

fixes: #4990
This commit is contained in:
Sojan Jose
2022-08-16 16:58:23 +05:30
committed by GitHub
parent 287f0a6de0
commit 2ecb2ca0f0
20 changed files with 225 additions and 216 deletions

View File

@@ -23,8 +23,8 @@ module AssignmentHandler
def find_assignee_from_team
return if team&.allow_auto_assign.blank?
team_members = inbox.members.ids & team.members.ids
::RoundRobin::AssignmentService.new(conversation: self, allowed_member_ids: team_members).find_assignee
team_members_with_capacity = inbox.member_ids_with_assignment_capacity & team.members.ids
::AutoAssignment::AgentAssignmentService.new(conversation: self, allowed_agent_ids: team_members_with_capacity).find_assignee
end
def notify_assignment_change

View File

@@ -1,23 +1,23 @@
module RoundRobinHandler
module AutoAssignmentHandler
extend ActiveSupport::Concern
include Events::Types
included do
after_save :run_round_robin
after_save :run_auto_assignment
end
private
def run_round_robin
def run_auto_assignment
# Round robin kicks in on conversation create & update
# run it only when conversation status changes to open
return unless conversation_status_changed_to_open?
return unless should_round_robin?
return unless should_run_auto_assignment?
::RoundRobin::AssignmentService.new(conversation: self, allowed_member_ids: inbox.member_ids_with_assignment_capacity).perform
::AutoAssignment::AgentAssignmentService.new(conversation: self, allowed_agent_ids: inbox.member_ids_with_assignment_capacity).perform
end
def should_round_robin?
def should_run_auto_assignment?
return false unless inbox.enable_auto_assignment?
# run only if assignee is blank or doesn't have access to inbox

View File

@@ -41,7 +41,7 @@
class Conversation < ApplicationRecord
include Labelable
include AssignmentHandler
include RoundRobinHandler
include AutoAssignmentHandler
include ActivityMessageHandler
include UrlHelper
include SortHandler

View File

@@ -136,7 +136,7 @@ class Inbox < ApplicationRecord
end
def delete_round_robin_agents
::RoundRobin::ManageService.new(inbox: self).clear_queue
::AutoAssignment::InboxRoundRobinService.new(inbox: self).clear_queue
end
def check_channel_type?

View File

@@ -28,10 +28,10 @@ class InboxMember < ApplicationRecord
private
def add_agent_to_round_robin
::RoundRobin::ManageService.new(inbox: inbox).add_agent_to_queue(user_id)
::AutoAssignment::InboxRoundRobinService.new(inbox: inbox).add_agent_to_queue(user_id)
end
def remove_agent_from_round_robin
::RoundRobin::ManageService.new(inbox: inbox).remove_agent_from_queue(user_id) if inbox.present?
::AutoAssignment::InboxRoundRobinService.new(inbox: inbox).remove_agent_from_queue(user_id) if inbox.present?
end
end