|
@@ -167,7 +167,7 @@ def escalation_calculation_get_sla
|
|
|
sla_selected = nil
|
|
|
sla_list = Cache.get( 'SLA::List::Active' )
|
|
|
if sla_list == nil
|
|
|
- sla_list = Sla.where( :active => true ).all
|
|
|
+ sla_list = Sla.where( :active => true )
|
|
|
Cache.write( 'SLA::List::Active', sla_list, { :expires_in => 1.hour } )
|
|
|
end
|
|
|
sla_list.each {|sla|
|
|
@@ -221,53 +221,52 @@ def escalation_calculation_get_sla
|
|
|
history_list.each { |history_item|
|
|
|
|
|
|
# ignore if it isn't a state change
|
|
|
- next if !history_item.history_attribute_id
|
|
|
- history_attribute = History::Attribute.lookup( :id => history_item.history_attribute_id );
|
|
|
- next if history_attribute.name != 'ticket_state'
|
|
|
+ next if !history_item['attribute']
|
|
|
+ next if history_item['attribute'] != 'ticket_state'
|
|
|
|
|
|
# ignore all newer state before start_time
|
|
|
- next if history_item.created_at < start_time
|
|
|
+ next if history_item['created_at'] < start_time
|
|
|
|
|
|
# ignore all older state changes after end_time
|
|
|
next if last_state_change && last_state_change > end_time
|
|
|
|
|
|
# if created_at is later then end_time, use end_time as last time
|
|
|
- if history_item.created_at > end_time
|
|
|
- history_item.created_at = end_time
|
|
|
+ if history_item['created_at'] > end_time
|
|
|
+ history_item['created_at'] = end_time
|
|
|
end
|
|
|
|
|
|
# get initial state and time
|
|
|
if !last_state
|
|
|
- last_state = history_item.value_from
|
|
|
+ last_state = history_item['value_from']
|
|
|
last_state_change = start_time
|
|
|
end
|
|
|
|
|
|
# check if time need to be counted
|
|
|
counted = true
|
|
|
- if history_item.value_from == 'pending'
|
|
|
+ if history_item['value_from'] == 'pending'
|
|
|
counted = false
|
|
|
- elsif history_item.value_from == 'close'
|
|
|
+ elsif history_item['value_from'] == 'close'
|
|
|
counted = false
|
|
|
end
|
|
|
|
|
|
- diff = escalation_time_diff( last_state_change, history_item.created_at, sla_selected )
|
|
|
+ diff = escalation_time_diff( last_state_change, history_item['created_at'], sla_selected )
|
|
|
if counted
|
|
|
- puts "Diff count #{history_item.value_from} -> #{history_item.value_to} / #{last_state_change} -> #{history_item.created_at}"
|
|
|
+ puts "Diff count #{history_item['value_from']} -> #{history_item['value_to']} / #{last_state_change} -> #{history_item['created_at']}"
|
|
|
total_time_without_pending = total_time_without_pending + diff
|
|
|
else
|
|
|
- puts "Diff not count #{history_item.value_from} -> #{history_item.value_to} / #{last_state_change} -> #{history_item.created_at}"
|
|
|
+ puts "Diff not count #{history_item['value_from']} -> #{history_item['value_to']} / #{last_state_change} -> #{history_item['created_at']}"
|
|
|
end
|
|
|
total_time = total_time + diff
|
|
|
|
|
|
- if history_item.value_to == 'pending'
|
|
|
+ if history_item['value_to'] == 'pending'
|
|
|
last_state_is_pending = true
|
|
|
else
|
|
|
last_state_is_pending = false
|
|
|
end
|
|
|
|
|
|
# remember for next loop last state
|
|
|
- last_state = history_item.value_to
|
|
|
- last_state_change = history_item.created_at
|
|
|
+ last_state = history_item['value_to']
|
|
|
+ last_state_change = history_item['created_at']
|
|
|
}
|
|
|
|
|
|
# if last state isnt pending, count rest
|