review changes

This commit is contained in:
Tanmay Deep Sharma
2025-11-12 17:59:52 +05:30
parent 3c7b4f6011
commit 44da47c845
7 changed files with 29 additions and 22 deletions
@@ -13,13 +13,6 @@ module Enterprise::AutoAssignment::AssignmentService
}.compact
end
# Override to check policy first
def assignment_enabled?
return policy.enabled? if policy
super
end
# Extend agent finding to add capacity checks
def find_available_agent
agents = filter_agents_by_rate_limit(inbox.available_agents)
@@ -65,11 +58,11 @@ module Enterprise::AutoAssignment::AssignmentService
# Apply exclusion rules from capacity policy or assignment policy
scope = apply_exclusion_rules(scope)
# Apply conversation priority from config
scope = if assignment_config['conversation_priority'] == 'longest_waiting'
scope.order(last_activity_at: :asc, created_at: :asc)
# Apply conversation priority using enum methods if policy exists
scope = if policy&.longest_waiting?
scope.reorder(last_activity_at: :asc, created_at: :asc)
else
scope.order(created_at: :asc)
scope.reorder(created_at: :asc)
end
scope.limit(limit)