Compare commits

...
3 changed files with 11 additions and 3 deletions
+2
View File
@@ -22,6 +22,8 @@
# index_assignment_policies_on_enabled (enabled)
#
class AssignmentPolicy < ApplicationRecord
DEFAULT_EXCLUDE_OLDER_THAN_HOURS = 168
belongs_to :account
has_many :inbox_assignment_policies, dependent: :destroy
has_many :inboxes, through: :inbox_assignment_policies
@@ -35,9 +35,9 @@ class AutoAssignment::AssignmentService
def unassigned_conversations(limit)
scope = inbox.conversations.unassigned.open
# Skip stale backlog with no activity beyond the policy's age threshold (defaults to 7 days)
# Skip stale backlog with no activity beyond the age threshold
policy = inbox.assignment_policy
scope = apply_age_exclusions(scope, policy&.exclude_older_than_hours)
scope = apply_age_exclusions(scope, age_exclusion_hours(policy))
# Apply conversation priority using assignment policy if available
scope = if policy&.longest_waiting?
@@ -49,6 +49,12 @@ class AutoAssignment::AssignmentService
scope.limit(limit)
end
def age_exclusion_hours(policy)
return policy.exclude_older_than_hours if policy
AssignmentPolicy::DEFAULT_EXCLUDE_OLDER_THAN_HOURS
end
def apply_age_exclusions(scope, hours_threshold)
return scope if hours_threshold.blank?
@@ -60,7 +60,7 @@ module Enterprise::AutoAssignment::AssignmentService
scope = inbox.conversations.unassigned.open
# First apply the assignment policy's age exclusion (defaults to 7 days)
scope = apply_age_exclusions(scope, policy&.exclude_older_than_hours)
scope = apply_age_exclusions(scope, age_exclusion_hours(policy))
# Then apply the capacity policy's exclusion rules (labels and age)
scope = apply_exclusion_rules(scope)