user_ticket_counter.rb 663 B

12345678910111213141516171819202122232425262728
  1. # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
  2. class Observer::Ticket::UserTicketCounter < ActiveRecord::Observer
  3. observe 'ticket'
  4. def after_commit(record)
  5. user_ticket_counter_update(record)
  6. end
  7. def user_ticket_counter_update(record)
  8. # return if we run import mode
  9. return true if Setting.get('import_mode')
  10. return true if record.destroyed?
  11. return true if !record.customer_id
  12. # send background job
  13. Delayed::Job.enqueue(
  14. Observer::Ticket::UserTicketCounter::BackgroundJob.new(
  15. record.customer_id,
  16. UserInfo.current_user_id || record.updated_by_id,
  17. )
  18. )
  19. end
  20. end