From 36070738f170f8d88a88d18f59a4bfb71df2fd49 Mon Sep 17 00:00:00 2001 From: Tanmay Sharma Date: Wed, 6 Aug 2025 18:03:56 +0530 Subject: [PATCH] remove the extra file --- .../assignment_v2/capacity_service.rb | 58 ------------------- 1 file changed, 58 deletions(-) delete mode 100644 enterprise/app/services/assignment_v2/capacity_service.rb diff --git a/enterprise/app/services/assignment_v2/capacity_service.rb b/enterprise/app/services/assignment_v2/capacity_service.rb deleted file mode 100644 index d3756e431..000000000 --- a/enterprise/app/services/assignment_v2/capacity_service.rb +++ /dev/null @@ -1,58 +0,0 @@ -# frozen_string_literal: true - -class Enterprise::AssignmentV2::CapacityService - pattr_initialize [:inbox!] - - def filter_agents_by_capacity(inbox_members) - inbox_members.select do |inbox_member| - agent = inbox_member.user - available_capacity?(agent) - end - end - - def get_agent_capacity(agent) - inbox_limit = get_inbox_limit_for_agent(agent) - return unlimited_capacity unless inbox_limit - - current_count = count_current_assignments(agent) - build_capacity_data(inbox_limit, current_count) - end - - private - - def get_inbox_limit_for_agent(agent) - account_user = agent.account_users.find_by(account: inbox.account) - policy = account_user&.agent_capacity_policy - return nil unless policy - - policy.inbox_capacity_limits.find_by(inbox: inbox) - end - - def count_current_assignments(agent) - agent.assigned_conversations - .where(inbox: inbox) - .open - .count - end - - def build_capacity_data(inbox_limit, current_count) - { - total_capacity: inbox_limit.conversation_limit, - current_assignments: current_count, - available_capacity: inbox_limit.conversation_limit - current_count - } - end - - def unlimited_capacity - { - total_capacity: Float::INFINITY, - current_assignments: 0, - available_capacity: Float::INFINITY - } - end - - def available_capacity?(agent) - capacity_data = get_agent_capacity(agent) - capacity_data[:available_capacity].positive? - end -end