Moved escalation_calculation_get_sla to public.

This commit is contained in:
Martin Edenhofer 2013-08-26 01:04:41 +02:00
parent 5b7cd7e478
commit 49896bbcef

View file

@ -150,6 +150,55 @@ returns
self.save
end
=begin
return sla for ticket
ticket = Ticket.find(123)
result = ticket.escalation_calculation_get_sla
returns
result = selected_sla
=end
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
Cache.write( 'SLA::List::Active', sla_list, { :expires_in => 1.hour } )
end
sla_list.each {|sla|
if !sla.condition || sla.condition.empty?
sla_selected = sla
elsif sla.condition
hit = false
map = [
[ 'tickets.ticket_priority_id', 'ticket_priority_id' ],
[ 'tickets.group_id', 'group_id' ]
]
map.each {|item|
if sla.condition[ item[0] ]
if sla.condition[ item[0] ].class == String
sla.condition[ item[0] ] = [ sla.condition[ item[0] ] ]
end
if sla.condition[ item[0] ].include?( self[ item[1] ].to_s )
hit = true
else
hit = false
end
end
}
if hit
sla_selected = sla
end
end
}
sla_selected
end
private
#type could be:
@ -257,44 +306,6 @@ returns
diff
end
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
Cache.write( 'SLA::List::Active', sla_list, { :expires_in => 1.hour } )
end
sla_list.each {|sla|
if !sla.condition || sla.condition.empty?
sla_selected = sla
elsif sla.condition
hit = false
map = [
[ 'tickets.ticket_priority_id', 'ticket_priority_id' ],
[ 'tickets.group_id', 'group_id' ]
]
map.each {|item|
if sla.condition[ item[0] ]
if sla.condition[ item[0] ].class == String
sla.condition[ item[0] ] = [ sla.condition[ item[0] ] ]
end
if sla.condition[ item[0] ].include?( self[ item[1] ].to_s )
hit = true
else
hit = false
end
end
}
if hit
sla_selected = sla
end
end
}
return sla_selected
end
def calculation_higher_time(escalation_time, check_time, done_time)
return escalation_time if done_time
return check_time if !escalation_time