feat: Add support for minutes in auto resolve feature (#11269)
### Summary - Converts conversation auto-resolution duration from days to minutes for more granular control - Updates validation to allow values from 10 minutes (minimum) to 999 days (maximum) - Implements smart messaging to show appropriate time units in activity messages ### Changes - Created migration to convert existing durations from days to minutes (x1440) - Updated conversation resolver to use minutes instead of days - Added dynamic translation key selection based on duration value - Updated related specs and documentation - Added support for displaying durations in days, hours, or minutes based on value ### Test plan - Verify account validation accepts new minute-based ranges - Confirm existing account settings are correctly migrated - Test auto-resolution works properly with minute values - Ensure proper time unit display in activity messages --------- Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
This commit is contained in:
@@ -11,7 +11,7 @@ RSpec.describe Account::ConversationsResolutionSchedulerJob do
|
||||
end
|
||||
|
||||
it 'enqueues Conversations::ResolutionJob' do
|
||||
account.update(auto_resolve_duration: 10)
|
||||
account.update(auto_resolve_after: 10 * 60 * 24)
|
||||
expect(Conversations::ResolutionJob).to receive(:perform_later).with(account: account).once
|
||||
described_class.perform_now
|
||||
end
|
||||
|
||||
@@ -18,16 +18,17 @@ RSpec.describe Conversations::ResolutionJob do
|
||||
end
|
||||
|
||||
it 'resolves the issue if time of inactivity is more than the auto resolve duration' do
|
||||
account.update(auto_resolve_duration: 10)
|
||||
conversation.update(last_activity_at: 13.days.ago)
|
||||
account.update(auto_resolve_after: 14_400) # 10 days in minutes
|
||||
conversation.update(last_activity_at: 13.days.ago, waiting_since: nil)
|
||||
described_class.perform_now(account: account)
|
||||
expect(conversation.reload.status).to eq('resolved')
|
||||
end
|
||||
|
||||
it 'resolved only a limited number of conversations in a single execution' do
|
||||
stub_const('Limits::BULK_ACTIONS_LIMIT', 2)
|
||||
account.update(auto_resolve_duration: 10)
|
||||
create_list(:conversation, 3, account: account, last_activity_at: 13.days.ago)
|
||||
account.update(auto_resolve_after: 14_400) # 10 days in minutes
|
||||
conversations = create_list(:conversation, 3, account: account, last_activity_at: 13.days.ago)
|
||||
conversations.each { |conversation| conversation.update(waiting_since: nil) }
|
||||
described_class.perform_now(account: account)
|
||||
expect(account.conversations.resolved.count).to eq(Limits::BULK_ACTIONS_LIMIT)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user