has_escalation_calculation_impact.rb 947 B

1234567891011121314151617181920212223242526272829303132
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. module HasEscalationCalculationImpact
  3. extend ActiveSupport::Concern
  4. included do
  5. after_commit :enqueue_ticket_escalation_rebuild_job
  6. end
  7. private
  8. def enqueue_ticket_escalation_rebuild_job
  9. # return if we run import mode
  10. return if Setting.get('import_mode') && !Setting.get('import_ignore_sla')
  11. # check if condition has changed
  12. fields_to_check = if instance_of?(Sla)
  13. %w[condition calendar_id first_response_time update_time solution_time]
  14. else
  15. %w[timezone business_hours default ical_url public_holidays]
  16. end
  17. return if fields_to_check.none? do |item|
  18. next if !saved_change_to_attribute(item)
  19. saved_change_to_attribute(item)[0] != saved_change_to_attribute(item)[1]
  20. end
  21. TicketEscalationRebuildJob.perform_later
  22. end
  23. end