Small improvement to make escalation_calculation() smaller.
This commit is contained in:
parent
710773255e
commit
a2aaa8c2ce
1 changed files with 14 additions and 25 deletions
|
@ -755,11 +755,7 @@ class Ticket < ApplicationModel
|
||||||
|
|
||||||
# use time if ticket got from e. g. open to pending
|
# use time if ticket got from e. g. open to pending
|
||||||
if history_item['value_from'] != 'pending' && history_item['value_to'] == 'pending'
|
if history_item['value_from'] != 'pending' && history_item['value_to'] == 'pending'
|
||||||
if sla_selected
|
diff = self.escalation_time_diff( last_state_change, history_item['created_at'], sla_selected )
|
||||||
diff = TimeCalculation.business_time_diff( last_state_change, history_item['created_at'],sla_selected.data, sla_selected.timezone)
|
|
||||||
else
|
|
||||||
diff = TimeCalculation.business_time_diff( last_state_change, history_item['created_at'] )
|
|
||||||
end
|
|
||||||
puts "Diff count !=pending -> ==pending #{diff.to_s} - #{last_state_change} - #{history_item['created_at']}"
|
puts "Diff count !=pending -> ==pending #{diff.to_s} - #{last_state_change} - #{history_item['created_at']}"
|
||||||
total_time_without_pending = total_time_without_pending + diff
|
total_time_without_pending = total_time_without_pending + diff
|
||||||
total_time = total_time + diff
|
total_time = total_time + diff
|
||||||
|
@ -767,21 +763,13 @@ class Ticket < ApplicationModel
|
||||||
|
|
||||||
# use time if ticket got from e. g. open to open
|
# use time if ticket got from e. g. open to open
|
||||||
elsif history_item['value_from'] != 'pending' && history_item['value_to'] != 'pending'
|
elsif history_item['value_from'] != 'pending' && history_item['value_to'] != 'pending'
|
||||||
if sla_selected
|
diff = self.escalation_time_diff( last_state_change, history_item['created_at'], sla_selected )
|
||||||
diff = TimeCalculation.business_time_diff( last_state_change, history_item['created_at'], sla_selected.data, sla_selected.timezone)
|
|
||||||
else
|
|
||||||
diff = TimeCalculation.business_time_diff( last_state_change, history_item['created_at'] )
|
|
||||||
end
|
|
||||||
puts "Diff count !=pending -> !=pending #{diff.to_s} - #{last_state_change} - #{history_item['created_at']}"
|
puts "Diff count !=pending -> !=pending #{diff.to_s} - #{last_state_change} - #{history_item['created_at']}"
|
||||||
total_time_without_pending = total_time_without_pending + diff
|
total_time_without_pending = total_time_without_pending + diff
|
||||||
total_time = total_time + diff
|
total_time = total_time + diff
|
||||||
last_state_is_pending = false
|
last_state_is_pending = false
|
||||||
elsif history_item['value_from'] == 'pending' && history_item['value_to'] != 'pending'
|
elsif history_item['value_from'] == 'pending' && history_item['value_to'] != 'pending'
|
||||||
if sla_selected
|
diff = self.escalation_time_diff( last_state_change, history_item['created_at'], sla_selected )
|
||||||
diff = TimeCalculation.business_time_diff( last_state_change, history_item['created_at'], sla_selected.data, sla_selected.timezone)
|
|
||||||
else
|
|
||||||
diff = TimeCalculation.business_time_diff( last_state_change, history_item['created_at'] )
|
|
||||||
end
|
|
||||||
puts "Diff not count ==pending -> !=pending #{diff.to_s} - #{last_state_change} - #{history_item['created_at']}"
|
puts "Diff not count ==pending -> !=pending #{diff.to_s} - #{last_state_change} - #{history_item['created_at']}"
|
||||||
total_time = total_time + diff
|
total_time = total_time + diff
|
||||||
last_state_is_pending = false
|
last_state_is_pending = false
|
||||||
|
@ -798,11 +786,7 @@ class Ticket < ApplicationModel
|
||||||
|
|
||||||
# if last state isnt pending, count rest
|
# if last state isnt pending, count rest
|
||||||
if !last_state_is_pending && last_state_change && last_state_change < end_time
|
if !last_state_is_pending && last_state_change && last_state_change < end_time
|
||||||
if sla_selected
|
diff = self.escalation_time_diff( last_state_change, end_time, sla_selected )
|
||||||
diff = TimeCalculation.business_time_diff( last_state_change, end_time, sla_selected.data, sla_selected.timezone)
|
|
||||||
else
|
|
||||||
diff = TimeCalculation.business_time_diff( last_state_change, end_time )
|
|
||||||
end
|
|
||||||
puts "Diff count last state was not pending #{diff.to_s} - #{last_state_change} - #{end_time}"
|
puts "Diff count last state was not pending #{diff.to_s} - #{last_state_change} - #{end_time}"
|
||||||
total_time_without_pending = total_time_without_pending + diff
|
total_time_without_pending = total_time_without_pending + diff
|
||||||
total_time = total_time + diff
|
total_time = total_time + diff
|
||||||
|
@ -810,11 +794,7 @@ class Ticket < ApplicationModel
|
||||||
|
|
||||||
# if we have not had any state change
|
# if we have not had any state change
|
||||||
if !last_state_change
|
if !last_state_change
|
||||||
if sla_selected
|
diff = self.escalation_time_diff( start_time, end_time, sla_selected )
|
||||||
diff = TimeCalculation.business_time_diff( start_time, end_time, sla_selected.data, sla_selected.timezone)
|
|
||||||
else
|
|
||||||
diff = TimeCalculation.business_time_diff( start_time, end_time )
|
|
||||||
end
|
|
||||||
puts 'Diff state has not changed ' + diff.to_s
|
puts 'Diff state has not changed ' + diff.to_s
|
||||||
total_time_without_pending = total_time_without_pending + diff
|
total_time_without_pending = total_time_without_pending + diff
|
||||||
total_time = total_time + diff
|
total_time = total_time + diff
|
||||||
|
@ -831,6 +811,15 @@ class Ticket < ApplicationModel
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def escalation_time_diff( start_time, end_time, sla_selected )
|
||||||
|
if sla_selected
|
||||||
|
diff = TimeCalculation.business_time_diff( start_time, end_time, sla_selected.data, sla_selected.timezone)
|
||||||
|
else
|
||||||
|
diff = TimeCalculation.business_time_diff( start_time, end_time )
|
||||||
|
end
|
||||||
|
diff
|
||||||
|
end
|
||||||
|
|
||||||
class Number
|
class Number
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue