Improved escalation calculation.
This commit is contained in:
parent
1b253f402e
commit
b30ef07940
2 changed files with 138 additions and 27 deletions
|
@ -580,10 +580,6 @@ class Ticket < ApplicationModel
|
||||||
self.escalation_time = self._escalation_calculation_higher_time( self.escalation_time, self.first_response_escal_date, self.first_response )
|
self.escalation_time = self._escalation_calculation_higher_time( self.escalation_time, self.first_response_escal_date, self.first_response )
|
||||||
end
|
end
|
||||||
if self.first_response# && !self.first_response_in_min
|
if self.first_response# && !self.first_response_in_min
|
||||||
# created_at = Time.parse(self.created_at.to_s)
|
|
||||||
# first_response_at = Time.parse(self.first_response.to_s)
|
|
||||||
# diff = created_at.business_time_until(first_response_at) / 60
|
|
||||||
# self.first_response_in_min = diff.round
|
|
||||||
self.first_response_in_min = self._escalation_calculation_business_time_diff( self.created_at, self.first_response )
|
self.first_response_in_min = self._escalation_calculation_business_time_diff( self.created_at, self.first_response )
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -592,24 +588,27 @@ class Ticket < ApplicationModel
|
||||||
self.first_response_diff_in_min = sla_selected.first_response_time - self.first_response_in_min
|
self.first_response_diff_in_min = sla_selected.first_response_time - self.first_response_in_min
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
# update time
|
# update time
|
||||||
if sla_selected.update_time
|
|
||||||
last_update = self.last_contact_agent
|
last_update = self.last_contact_agent
|
||||||
if !last_update
|
if !last_update
|
||||||
last_update = self.created_at
|
last_update = self.created_at
|
||||||
end
|
end
|
||||||
|
if sla_selected.update_time
|
||||||
self.update_time_escal_date = self._escalation_calculation_dest_time( last_update, sla_selected.update_time )
|
self.update_time_escal_date = self._escalation_calculation_dest_time( last_update, sla_selected.update_time )
|
||||||
|
|
||||||
# set ticket escalation
|
# set ticket escalation
|
||||||
self.escalation_time = self._escalation_calculation_higher_time( self.escalation_time, self.update_time_escal_date, false )
|
self.escalation_time = self._escalation_calculation_higher_time( self.escalation_time, self.update_time_escal_date, false )
|
||||||
end
|
end
|
||||||
|
if self.last_contact_agent
|
||||||
|
self.update_time_in_min = self._escalation_calculation_business_time_diff( self.created_at, self.last_contact_agent )
|
||||||
|
end
|
||||||
|
|
||||||
|
# set sla time
|
||||||
|
if sla_selected.update_time && self.update_time_in_min
|
||||||
|
self.update_time_diff_in_min = sla_selected.update_time - self.update_time_in_min
|
||||||
|
end
|
||||||
|
|
||||||
# if self.last_contact_agent && !self.update_time_in_min
|
|
||||||
# created_at = Time.parse(self.created_at.to_s)
|
|
||||||
# last_contact_agent = Time.parse(self.last_contact_agent.to_s)
|
|
||||||
# diff = created_at.business_time_until(closed_at) / 60
|
|
||||||
# self.close_time_in_min = diff.round
|
|
||||||
# end
|
|
||||||
|
|
||||||
# close time
|
# close time
|
||||||
if sla_selected.close_time
|
if sla_selected.close_time
|
||||||
|
@ -619,12 +618,7 @@ class Ticket < ApplicationModel
|
||||||
self.escalation_time = self._escalation_calculation_higher_time( self.escalation_time, self.close_time_escal_date, self.close_time )
|
self.escalation_time = self._escalation_calculation_higher_time( self.escalation_time, self.close_time_escal_date, self.close_time )
|
||||||
end
|
end
|
||||||
if self.close_time# && !self.close_time_in_min
|
if self.close_time# && !self.close_time_in_min
|
||||||
# created_at = Time.parse(self.created_at.to_s)
|
|
||||||
# closed_at = Time.parse(self.close_time.to_s)
|
|
||||||
# diff = created_at.business_time_until(closed_at) / 60
|
|
||||||
# self.close_time_in_min = diff.round
|
|
||||||
self.close_time_in_min = self._escalation_calculation_business_time_diff( self.created_at, self.close_time )
|
self.close_time_in_min = self._escalation_calculation_business_time_diff( self.created_at, self.close_time )
|
||||||
|
|
||||||
end
|
end
|
||||||
# set sla time
|
# set sla time
|
||||||
if sla_selected.close_time && self.close_time_in_min
|
if sla_selected.close_time && self.close_time_in_min
|
||||||
|
|
|
@ -81,11 +81,17 @@ class TicketTest < ActiveSupport::TestCase
|
||||||
assert_equal( ticket.first_response, nil, 'ticket.first_response verify 2' )
|
assert_equal( ticket.first_response, nil, 'ticket.first_response verify 2' )
|
||||||
assert_equal( ticket.first_response_in_min, nil, 'ticket.first_response_in_min verify 2' )
|
assert_equal( ticket.first_response_in_min, nil, 'ticket.first_response_in_min verify 2' )
|
||||||
assert_equal( ticket.first_response_diff_in_min, nil, 'ticket.first_response_diff_in_min verify 2' )
|
assert_equal( ticket.first_response_diff_in_min, nil, 'ticket.first_response_diff_in_min verify 2' )
|
||||||
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 11:30:00 UTC', 'ticket.update_time_escal_date verify 2' )
|
|
||||||
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 2' )
|
|
||||||
|
|
||||||
|
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 11:30:00 UTC', 'ticket.update_time_escal_date verify 2' )
|
||||||
|
assert_equal( ticket.update_time_in_min, nil, 'ticket.update_time_in_min verify 2' )
|
||||||
|
assert_equal( ticket.update_time_diff_in_min, nil, 'ticket.update_time_diff_in_min verify 2' )
|
||||||
|
|
||||||
|
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 2' )
|
||||||
|
assert_equal( ticket.close_time_in_min, nil, 'ticket.close_time_in_min verify 2' )
|
||||||
|
assert_equal( ticket.close_time_diff_in_min, nil, 'ticket.close_time_diff_in_min verify 2' )
|
||||||
|
|
||||||
|
# set first response in time
|
||||||
ticket.update_attributes(
|
ticket.update_attributes(
|
||||||
# :first_response_escal_date => '2013-03-26 09:30:00 UTC',
|
|
||||||
:first_response => '2013-03-21 10:00:00 UTC',
|
:first_response => '2013-03-21 10:00:00 UTC',
|
||||||
)
|
)
|
||||||
ticket.escalation_calculation
|
ticket.escalation_calculation
|
||||||
|
@ -96,11 +102,17 @@ class TicketTest < ActiveSupport::TestCase
|
||||||
assert_equal( ticket.first_response.gmtime.to_s, '2013-03-21 10:00:00 UTC', 'ticket.first_response verify 3' )
|
assert_equal( ticket.first_response.gmtime.to_s, '2013-03-21 10:00:00 UTC', 'ticket.first_response verify 3' )
|
||||||
assert_equal( ticket.first_response_in_min, 30, 'ticket.first_response_in_min verify 3' )
|
assert_equal( ticket.first_response_in_min, 30, 'ticket.first_response_in_min verify 3' )
|
||||||
assert_equal( ticket.first_response_diff_in_min, 30, 'ticket.first_response_diff_in_min verify 3' )
|
assert_equal( ticket.first_response_diff_in_min, 30, 'ticket.first_response_diff_in_min verify 3' )
|
||||||
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 11:30:00 UTC', 'ticket.update_time_escal_date verify 3' )
|
|
||||||
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 3' )
|
|
||||||
|
|
||||||
|
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 11:30:00 UTC', 'ticket.update_time_escal_date verify 3' )
|
||||||
|
assert_equal( ticket.update_time_in_min, nil, 'ticket.update_time_in_min verify 3' )
|
||||||
|
assert_equal( ticket.update_time_diff_in_min, nil, 'ticket.update_time_diff_in_min verify 3' )
|
||||||
|
|
||||||
|
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 3' )
|
||||||
|
assert_equal( ticket.close_time_in_min, nil, 'ticket.close_time_in_min verify 3' )
|
||||||
|
assert_equal( ticket.close_time_diff_in_min, nil, 'ticket.close_time_diff_in_min verify 3' )
|
||||||
|
|
||||||
|
# set first reponse over time
|
||||||
ticket.update_attributes(
|
ticket.update_attributes(
|
||||||
# :first_response_escal_date => '2013-03-26 09:30:00 UTC',
|
|
||||||
:first_response => '2013-03-21 14:00:00 UTC',
|
:first_response => '2013-03-21 14:00:00 UTC',
|
||||||
)
|
)
|
||||||
ticket.escalation_calculation
|
ticket.escalation_calculation
|
||||||
|
@ -111,9 +123,114 @@ class TicketTest < ActiveSupport::TestCase
|
||||||
assert_equal( ticket.first_response.gmtime.to_s, '2013-03-21 14:00:00 UTC', 'ticket.first_response verify 4' )
|
assert_equal( ticket.first_response.gmtime.to_s, '2013-03-21 14:00:00 UTC', 'ticket.first_response verify 4' )
|
||||||
assert_equal( ticket.first_response_in_min, 270, 'ticket.first_response_in_min verify 4' )
|
assert_equal( ticket.first_response_in_min, 270, 'ticket.first_response_in_min verify 4' )
|
||||||
assert_equal( ticket.first_response_diff_in_min, -210, 'ticket.first_response_diff_in_min verify 4' )
|
assert_equal( ticket.first_response_diff_in_min, -210, 'ticket.first_response_diff_in_min verify 4' )
|
||||||
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 11:30:00 UTC', 'ticket.update_time_escal_date verify 4' )
|
|
||||||
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 4' )
|
|
||||||
|
|
||||||
|
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 11:30:00 UTC', 'ticket.update_time_escal_date verify 4' )
|
||||||
|
assert_equal( ticket.update_time_in_min, nil, 'ticket.update_time_in_min verify 4' )
|
||||||
|
assert_equal( ticket.update_time_diff_in_min, nil, 'ticket.update_time_diff_in_min verify 4' )
|
||||||
|
|
||||||
|
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 4' )
|
||||||
|
assert_equal( ticket.close_time_in_min, nil, 'ticket.close_time_in_min verify 4' )
|
||||||
|
assert_equal( ticket.close_time_diff_in_min, nil, 'ticket.close_time_diff_in_min verify 4' )
|
||||||
|
|
||||||
|
# set update time in time
|
||||||
|
ticket.update_attributes(
|
||||||
|
:last_contact_agent => '2013-03-21 11:00:00 UTC',
|
||||||
|
)
|
||||||
|
ticket.escalation_calculation
|
||||||
|
assert_equal( ticket.escalation_time.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.escalation_time verify 5' )
|
||||||
|
|
||||||
|
assert_equal( ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.first_response_escal_date verify 5' )
|
||||||
|
assert_equal( ticket.first_response.gmtime.to_s, '2013-03-21 14:00:00 UTC', 'ticket.first_response verify 5' )
|
||||||
|
assert_equal( ticket.first_response_in_min, 270, 'ticket.first_response_in_min verify 5' )
|
||||||
|
assert_equal( ticket.first_response_diff_in_min, -210, 'ticket.first_response_diff_in_min verify 5' )
|
||||||
|
|
||||||
|
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 13:00:00 UTC', 'ticket.update_time_escal_date verify 5' )
|
||||||
|
assert_equal( ticket.update_time_in_min, 90, 'ticket.update_time_in_min verify 5' )
|
||||||
|
assert_equal( ticket.update_time_diff_in_min, 30, 'ticket.update_time_diff_in_min verify 5' )
|
||||||
|
|
||||||
|
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 5' )
|
||||||
|
assert_equal( ticket.close_time_in_min, nil, 'ticket.close_time_in_min verify 5' )
|
||||||
|
assert_equal( ticket.close_time_diff_in_min, nil, 'ticket.close_time_diff_in_min verify 5' )
|
||||||
|
|
||||||
|
# set update time over time
|
||||||
|
ticket.update_attributes(
|
||||||
|
:last_contact_agent => '2013-03-21 12:00:00 UTC',
|
||||||
|
)
|
||||||
|
ticket.escalation_calculation
|
||||||
|
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:00:00 UTC', 'ticket.update_time_escal_date verify 6' )
|
||||||
|
assert_equal( ticket.update_time_in_min, 150, 'ticket.update_time_in_min verify 6' )
|
||||||
|
assert_equal( ticket.update_time_diff_in_min, -30, '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
|
||||||
|
ticket.update_attributes(
|
||||||
|
:close_time => '2013-03-21 11:30:00 UTC',
|
||||||
|
)
|
||||||
|
ticket.escalation_calculation
|
||||||
|
assert_equal( ticket.escalation_time.gmtime.to_s, '2013-03-21 14:00: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.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_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_in_min, 150, '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.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_diff_in_min, 60, 'ticket.close_time_diff_in_min verify 7' )
|
||||||
|
|
||||||
|
# set close time over time
|
||||||
|
ticket.update_attributes(
|
||||||
|
:close_time => '2013-03-21 13:00:00 UTC',
|
||||||
|
)
|
||||||
|
ticket.escalation_calculation
|
||||||
|
assert_equal( ticket.escalation_time.gmtime.to_s, '2013-03-21 14:00: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.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_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_in_min, 150, '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.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_diff_in_min, -30, 'ticket.close_time_diff_in_min verify 8' )
|
||||||
|
|
||||||
|
# set close time over time
|
||||||
|
ticket.update_attributes(
|
||||||
|
:ticket_state => Ticket::State.lookup( :name => 'closed' )
|
||||||
|
)
|
||||||
|
ticket.escalation_calculation
|
||||||
|
assert_equal( ticket.escalation_time, nil, 'ticket.escalation_time verify 9' )
|
||||||
|
|
||||||
|
assert_equal( ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.first_response_escal_date verify 9' )
|
||||||
|
assert_equal( ticket.first_response.gmtime.to_s, '2013-03-21 14:00:00 UTC', 'ticket.first_response 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.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_in_min, 150, '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.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_diff_in_min, -30, 'ticket.close_time_diff_in_min verify 9' )
|
||||||
|
|
||||||
|
|
||||||
delete = sla.destroy
|
delete = sla.destroy
|
||||||
|
|
Loading…
Reference in a new issue