has_escalation_calculation_impact.rb 877 B

1234567891011121314151617181920212223242526272829303132333435
  1. # Copyright (C) 2012-2024 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. return if !needs_rebuilding?
  12. TicketEscalationRebuildJob.perform_later
  13. end
  14. def needs_rebuilding?
  15. case self
  16. when Sla
  17. return true if destroyed?
  18. %w[condition calendar_id first_response_time update_time solution_time].any? do |item|
  19. saved_change_to_attribute?(item)
  20. end
  21. when Calendar
  22. %w[timezone business_hours default ical_url public_holidays].any? do |item|
  23. saved_change_to_attribute?(item)
  24. end
  25. end
  26. end
  27. end