enqueues_user_ticket_counter_job.rb 744 B

1234567891011121314151617181920212223242526272829303132
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. # Adds a background job to update the user's ticket counter on ticket changes.
  3. module Ticket::EnqueuesUserTicketCounterJob
  4. extend ActiveSupport::Concern
  5. included do
  6. after_commit :enqueue_user_ticket_counter_job
  7. end
  8. private
  9. def enqueue_user_ticket_counter_job
  10. # return if we run import mode
  11. return true if Setting.get('import_mode')
  12. return true if BulkImportInfo.enabled?
  13. return true if destroyed?
  14. return true if !customer_id
  15. return true if previous_changes.blank?
  16. # send background job
  17. TicketUserTicketCounterJob.perform_later(
  18. customer_id,
  19. UserInfo.current_user_id || updated_by_id,
  20. )
  21. end
  22. end