diff --git a/app/models/ticket.rb b/app/models/ticket.rb index a90522c27..2b29a0611 100644 --- a/app/models/ticket.rb +++ b/app/models/ticket.rb @@ -521,7 +521,7 @@ class Ticket < ApplicationModel def self.escalation_calculation_rebuild ticket_state_list_open = Ticket::State.by_category( 'open' ) - + tickets = Ticket.where( :ticket_state_id => ticket_state_list_open ) tickets.each {|ticket| ticket.escalation_calculation @@ -577,10 +577,8 @@ class Ticket < ApplicationModel def escalation_calculation # set escalation off if ticket is already closed - ticket_state = Ticket::State.lookup( :id => self.ticket_state_id ) - ticket_state_type = Ticket::StateType.lookup( :id => ticket_state.state_type_id ) - ignore_escalation = ['removed', 'closed', 'merged', 'pending action'] - if ignore_escalation.include?( ticket_state_type.name ) + ticket_state = Ticket::State.lookup( :id => self.ticket_state_id ) + if ticket_state.ignore_escalation? self.escalation_time = nil # self.first_response_escal_date = nil # self.close_time_escal_date = nil diff --git a/app/models/ticket/state.rb b/app/models/ticket/state.rb index 734af04d3..258ef5150 100644 --- a/app/models/ticket/state.rb +++ b/app/models/ticket/state.rb @@ -10,6 +10,10 @@ list tickets by customer states = Ticket::State.by_category('open') # open|closed +returns: + + state objects + =end def self.by_category(category) @@ -24,4 +28,24 @@ list tickets by customer end raise "Unknown category '#{category}'" end + +=begin + +check if state is ignored for escalation + + ticket_state = Ticket::State.lookup( :name => 'state name' ) + + result = ticket_state.ignore_escalation? + +returns: + + true/false + +=end + + def ignore_escalation? + ignore_escalation = ['removed', 'closed', 'merged'] + return true if ignore_escalation.include?( self.name ) + return false + end end