trabajo-afectivo/app/models/concerns/has_escalation_calculation_impact.rb

33 lines
947 B
Ruby
Raw Normal View History

2022-01-01 13:38:12 +00:00
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
module HasEscalationCalculationImpact
extend ActiveSupport::Concern
included do
after_commit :enqueue_ticket_escalation_rebuild_job
end
private
def enqueue_ticket_escalation_rebuild_job
# return if we run import mode
return if Setting.get('import_mode') && !Setting.get('import_ignore_sla')
# check if condition has changed
fields_to_check = if instance_of?(Sla)
%w[condition calendar_id first_response_time update_time solution_time]
else
%w[timezone business_hours default ical_url public_holidays]
end
return if fields_to_check.none? do |item|
next if !saved_change_to_attribute(item)
saved_change_to_attribute(item)[0] != saved_change_to_attribute(item)[1]
end
TicketEscalationRebuildJob.perform_later
end
end