Improved escalation update time calculation.
This commit is contained in:
parent
e0293f08e5
commit
1fb3ac5133
2 changed files with 64 additions and 16 deletions
|
@ -82,6 +82,9 @@ returns
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
config.hours = hours
|
config.hours = hours
|
||||||
|
if !hours || hours.empty?
|
||||||
|
fail "No congifure hours found in calendar #{calendar.inspect}"
|
||||||
|
end
|
||||||
|
|
||||||
# get holidays
|
# get holidays
|
||||||
holidays = []
|
holidays = []
|
||||||
|
@ -123,11 +126,18 @@ returns
|
||||||
|
|
||||||
# update time
|
# update time
|
||||||
# calculate escalation
|
# calculate escalation
|
||||||
last_update = last_contact_agent
|
if !last_contact_customer && !last_contact_agent
|
||||||
if !last_update
|
|
||||||
last_update = created_at
|
last_update = created_at
|
||||||
|
elsif !last_contact_customer && last_contact_agent
|
||||||
|
last_update = last_contact_agent
|
||||||
|
elsif last_contact_customer && !last_contact_agent
|
||||||
|
last_update = last_contact_customer
|
||||||
|
elsif last_contact_agent > last_contact_customer
|
||||||
|
last_update = last_contact_agent
|
||||||
|
elsif last_contact_agent < last_contact_customer
|
||||||
|
last_update = last_contact_customer
|
||||||
end
|
end
|
||||||
if sla.update_time
|
if sla.update_time && last_update
|
||||||
self.update_time_escal_date = biz.time(sla.update_time, :minutes).after(last_update)
|
self.update_time_escal_date = biz.time(sla.update_time, :minutes).after(last_update)
|
||||||
pending_time = pending_minutes(last_update, update_time_escal_date, biz)
|
pending_time = pending_minutes(last_update, update_time_escal_date, biz)
|
||||||
if pending_time && pending_time > 0
|
if pending_time && pending_time > 0
|
||||||
|
@ -139,8 +149,8 @@ returns
|
||||||
end
|
end
|
||||||
|
|
||||||
# get update time in min
|
# get update time in min
|
||||||
if last_contact_agent
|
if last_update && last_update != created_at
|
||||||
self.update_time_in_min = pending_minutes(created_at, last_contact_agent, biz, 'business_minutes')
|
self.update_time_in_min = pending_minutes(created_at, last_update, biz, 'business_minutes')
|
||||||
end
|
end
|
||||||
|
|
||||||
# set sla time
|
# set sla time
|
||||||
|
|
|
@ -226,20 +226,58 @@ class TicketSlaTest < ActiveSupport::TestCase
|
||||||
assert_equal( ticket.close_time_in_min, nil, 'ticket.close_time_in_min verify 6' )
|
assert_equal( ticket.close_time_in_min, nil, 'ticket.close_time_in_min verify 6' )
|
||||||
assert_equal( ticket.close_time_diff_in_min, nil, 'ticket.close_time_diff_in_min verify 6' )
|
assert_equal( ticket.close_time_diff_in_min, nil, 'ticket.close_time_diff_in_min verify 6' )
|
||||||
|
|
||||||
|
# set update time over time
|
||||||
|
ticket.update_attributes(
|
||||||
|
last_contact_customer: '2013-03-21 12:05:00 UTC',
|
||||||
|
)
|
||||||
|
assert_equal( ticket.escalation_time.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.escalation_time verify 6' )
|
||||||
|
|
||||||
|
assert_equal( ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.first_response_escal_date verify 6' )
|
||||||
|
assert_equal( ticket.first_response.gmtime.to_s, '2013-03-21 14:00:00 UTC', 'ticket.first_response verify 6' )
|
||||||
|
assert_equal( ticket.first_response_in_min, 270, 'ticket.first_response_in_min verify 6' )
|
||||||
|
assert_equal( ticket.first_response_diff_in_min, -210, 'ticket.first_response_diff_in_min verify 6' )
|
||||||
|
|
||||||
|
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 14:05:00 UTC', 'ticket.update_time_escal_date verify 6' )
|
||||||
|
assert_equal( ticket.update_time_in_min, 155, 'ticket.update_time_in_min verify 6' )
|
||||||
|
assert_equal( ticket.update_time_diff_in_min, -35, 'ticket.update_time_diff_in_min verify 6' )
|
||||||
|
|
||||||
|
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 6' )
|
||||||
|
assert_equal( ticket.close_time_in_min, nil, 'ticket.close_time_in_min verify 6' )
|
||||||
|
assert_equal( ticket.close_time_diff_in_min, nil, 'ticket.close_time_diff_in_min verify 6' )
|
||||||
|
|
||||||
|
# set update time over time
|
||||||
|
ticket.update_attributes(
|
||||||
|
last_contact_agent: '2013-03-21 12:10:00 UTC',
|
||||||
|
)
|
||||||
|
assert_equal( ticket.escalation_time.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.escalation_time verify 6' )
|
||||||
|
|
||||||
|
assert_equal( ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.first_response_escal_date verify 6' )
|
||||||
|
assert_equal( ticket.first_response.gmtime.to_s, '2013-03-21 14:00:00 UTC', 'ticket.first_response verify 6' )
|
||||||
|
assert_equal( ticket.first_response_in_min, 270, 'ticket.first_response_in_min verify 6' )
|
||||||
|
assert_equal( ticket.first_response_diff_in_min, -210, 'ticket.first_response_diff_in_min verify 6' )
|
||||||
|
|
||||||
|
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 14:10:00 UTC', 'ticket.update_time_escal_date verify 6' )
|
||||||
|
assert_equal( ticket.update_time_in_min, 160, 'ticket.update_time_in_min verify 6' )
|
||||||
|
assert_equal( ticket.update_time_diff_in_min, -40, 'ticket.update_time_diff_in_min verify 6' )
|
||||||
|
|
||||||
|
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 6' )
|
||||||
|
assert_equal( ticket.close_time_in_min, nil, 'ticket.close_time_in_min verify 6' )
|
||||||
|
assert_equal( ticket.close_time_diff_in_min, nil, 'ticket.close_time_diff_in_min verify 6' )
|
||||||
|
|
||||||
# set close time in time
|
# set close time in time
|
||||||
ticket.update_attributes(
|
ticket.update_attributes(
|
||||||
close_time: '2013-03-21 11:30:00 UTC',
|
close_time: '2013-03-21 11:30:00 UTC',
|
||||||
)
|
)
|
||||||
assert_equal( ticket.escalation_time.gmtime.to_s, '2013-03-21 14:00:00 UTC', 'ticket.escalation_time verify 7' )
|
assert_equal( ticket.escalation_time.gmtime.to_s, '2013-03-21 14:10:00 UTC', 'ticket.escalation_time verify 7' )
|
||||||
|
|
||||||
assert_equal( ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.first_response_escal_date verify 7' )
|
assert_equal( ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.first_response_escal_date verify 7' )
|
||||||
assert_equal( ticket.first_response.gmtime.to_s, '2013-03-21 14:00:00 UTC', 'ticket.first_response verify 7' )
|
assert_equal( ticket.first_response.gmtime.to_s, '2013-03-21 14:00:00 UTC', 'ticket.first_response verify 7' )
|
||||||
assert_equal( ticket.first_response_in_min, 270, 'ticket.first_response_in_min verify 7' )
|
assert_equal( ticket.first_response_in_min, 270, 'ticket.first_response_in_min verify 7' )
|
||||||
assert_equal( ticket.first_response_diff_in_min, -210, 'ticket.first_response_diff_in_min verify 7' )
|
assert_equal( ticket.first_response_diff_in_min, -210, 'ticket.first_response_diff_in_min verify 7' )
|
||||||
|
|
||||||
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 14:00:00 UTC', 'ticket.update_time_escal_date verify 7' )
|
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 14:10:00 UTC', 'ticket.update_time_escal_date verify 7' )
|
||||||
assert_equal( ticket.update_time_in_min, 150, 'ticket.update_time_in_min verify 7' )
|
assert_equal( ticket.update_time_in_min, 160, 'ticket.update_time_in_min verify 7' )
|
||||||
assert_equal( ticket.update_time_diff_in_min, -30, 'ticket.update_time_diff_in_min verify 7' )
|
assert_equal( ticket.update_time_diff_in_min, -40, 'ticket.update_time_diff_in_min verify 7' )
|
||||||
|
|
||||||
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 7' )
|
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 7' )
|
||||||
assert_equal( ticket.close_time_in_min, 120, 'ticket.close_time_in_min verify 7' )
|
assert_equal( ticket.close_time_in_min, 120, 'ticket.close_time_in_min verify 7' )
|
||||||
|
@ -249,16 +287,16 @@ class TicketSlaTest < ActiveSupport::TestCase
|
||||||
ticket.update_attributes(
|
ticket.update_attributes(
|
||||||
close_time: '2013-03-21 13:00:00 UTC',
|
close_time: '2013-03-21 13:00:00 UTC',
|
||||||
)
|
)
|
||||||
assert_equal( ticket.escalation_time.gmtime.to_s, '2013-03-21 14:00:00 UTC', 'ticket.escalation_time verify 8' )
|
assert_equal( ticket.escalation_time.gmtime.to_s, '2013-03-21 14:10:00 UTC', 'ticket.escalation_time verify 8' )
|
||||||
|
|
||||||
assert_equal( ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.first_response_escal_date verify 8' )
|
assert_equal( ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.first_response_escal_date verify 8' )
|
||||||
assert_equal( ticket.first_response.gmtime.to_s, '2013-03-21 14:00:00 UTC', 'ticket.first_response verify 8' )
|
assert_equal( ticket.first_response.gmtime.to_s, '2013-03-21 14:00:00 UTC', 'ticket.first_response verify 8' )
|
||||||
assert_equal( ticket.first_response_in_min, 270, 'ticket.first_response_in_min verify 8' )
|
assert_equal( ticket.first_response_in_min, 270, 'ticket.first_response_in_min verify 8' )
|
||||||
assert_equal( ticket.first_response_diff_in_min, -210, 'ticket.first_response_diff_in_min verify 8' )
|
assert_equal( ticket.first_response_diff_in_min, -210, 'ticket.first_response_diff_in_min verify 8' )
|
||||||
|
|
||||||
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 14:00:00 UTC', 'ticket.update_time_escal_date verify 8' )
|
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 14:10:00 UTC', 'ticket.update_time_escal_date verify 8' )
|
||||||
assert_equal( ticket.update_time_in_min, 150, 'ticket.update_time_in_min verify 8' )
|
assert_equal( ticket.update_time_in_min, 160, 'ticket.update_time_in_min verify 8' )
|
||||||
assert_equal( ticket.update_time_diff_in_min, -30, 'ticket.update_time_diff_in_min verify 8' )
|
assert_equal( ticket.update_time_diff_in_min, -40, 'ticket.update_time_diff_in_min verify 8' )
|
||||||
|
|
||||||
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 8' )
|
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 8' )
|
||||||
assert_equal( ticket.close_time_in_min, 210, 'ticket.close_time_in_min verify 8' )
|
assert_equal( ticket.close_time_in_min, 210, 'ticket.close_time_in_min verify 8' )
|
||||||
|
@ -275,9 +313,9 @@ class TicketSlaTest < ActiveSupport::TestCase
|
||||||
assert_equal( ticket.first_response_in_min, 270, 'ticket.first_response_in_min verify 9' )
|
assert_equal( ticket.first_response_in_min, 270, 'ticket.first_response_in_min verify 9' )
|
||||||
assert_equal( ticket.first_response_diff_in_min, -210, 'ticket.first_response_diff_in_min verify 9' )
|
assert_equal( ticket.first_response_diff_in_min, -210, 'ticket.first_response_diff_in_min verify 9' )
|
||||||
|
|
||||||
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 14:00:00 UTC', 'ticket.update_time_escal_date verify 9' )
|
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 14:10:00 UTC', 'ticket.update_time_escal_date verify 9' )
|
||||||
assert_equal( ticket.update_time_in_min, 150, 'ticket.update_time_in_min verify 9' )
|
assert_equal( ticket.update_time_in_min, 160, 'ticket.update_time_in_min verify 9' )
|
||||||
assert_equal( ticket.update_time_diff_in_min, -30, 'ticket.update_time_diff_in_min verify 9' )
|
assert_equal( ticket.update_time_diff_in_min, -40, 'ticket.update_time_diff_in_min verify 9' )
|
||||||
|
|
||||||
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 9' )
|
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 9' )
|
||||||
assert_equal( ticket.close_time_in_min, 210, 'ticket.close_time_in_min verify 9' )
|
assert_equal( ticket.close_time_in_min, 210, 'ticket.close_time_in_min verify 9' )
|
||||||
|
|
Loading…
Reference in a new issue