escalation_calculation.rb 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
  2. class Observer::Ticket::EscalationCalculation < ActiveRecord::Observer
  3. observe 'ticket', 'ticket::_article'
  4. def after_create(record)
  5. # return if we run import mode
  6. return if Setting.get('import_mode') && !Setting.get('import_ignore_sla')
  7. # do not recalculation if first respons is already out
  8. if record.class.name == 'Ticket::Article'
  9. record.ticket.escalation_calculation
  10. return true
  11. end
  12. # update escalation
  13. return if record.callback_loop
  14. record.callback_loop = true
  15. record.escalation_calculation
  16. record.callback_loop = false
  17. end
  18. def after_update(record)
  19. # return if we run import mode
  20. return if Setting.get('import_mode') && !Setting.get('import_ignore_sla')
  21. # do not recalculation if first respons is already out
  22. if record.class.name == 'Ticket::Article'
  23. record.ticket.escalation_calculation
  24. return true
  25. end
  26. # update escalation
  27. return if record.callback_loop
  28. record.callback_loop = true
  29. record.escalation_calculation
  30. record.callback_loop = false
  31. end
  32. end