background_job_search_index.rb 495 B

123456789101112131415161718192021
  1. # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
  2. class BackgroundJobSearchIndex
  3. def initialize(object, o_id)
  4. @object = object
  5. @o_id = o_id
  6. end
  7. def perform
  8. record = @object.constantize.lookup(id: @o_id)
  9. return if !exists?(record)
  10. record.search_index_update_backend
  11. end
  12. private
  13. def exists?(record)
  14. return true if record
  15. Rails.logger.info "Can't index #{@object}.lookup(id: #{@o_id}), no such record found"
  16. false
  17. end
  18. end