Files
leadchat/enterprise/app/models/inbox_capacity_limit.rb
Tanmay Deep Sharma 5fd3d5e036 feat: allow zero conversation limit capacity policy (#13964)
## Description

Two improvements to Agent Capacity Policy:

**1. Support exclusion via zero conversation limit**
Allow `conversation_limit` to be `0` on inbox capacity limits. Agents
with a zero limit are excluded from auto-assignment for that inbox while
remaining members for manual assignment.

**2. Fix exclusion rules duration input**
- Default changed from `10` to `null` so time-based exclusion isn't
applied unless explicitly set.
- Minimum lowered from 10 to 1 minute.
- `DurationInput` updated to handle `null` values correctly.

## Type of change

Please delete options that are not relevant.

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)

## How Has This Been Tested?

- Added model and capacity service specs for zero-limit exclusion
behavior.
- Tested manually via UI flows 

## Checklist:

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented on my code, particularly in hard-to-understand
areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream
modules

---------

Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
2026-04-06 11:39:14 +05:30

25 lines
977 B
Ruby

# == Schema Information
#
# Table name: inbox_capacity_limits
#
# id :bigint not null, primary key
# conversation_limit :integer not null
# created_at :datetime not null
# updated_at :datetime not null
# agent_capacity_policy_id :bigint not null
# inbox_id :bigint not null
#
# Indexes
#
# idx_on_agent_capacity_policy_id_inbox_id_71c7ec4caf (agent_capacity_policy_id,inbox_id) UNIQUE
# index_inbox_capacity_limits_on_agent_capacity_policy_id (agent_capacity_policy_id)
# index_inbox_capacity_limits_on_inbox_id (inbox_id)
#
class InboxCapacityLimit < ApplicationRecord
belongs_to :agent_capacity_policy
belongs_to :inbox
validates :conversation_limit, presence: true, numericality: { greater_than_or_equal_to: 0, only_integer: true }
validates :inbox_id, uniqueness: { scope: :agent_capacity_policy_id }
end