2017-01-31 17:13:45 +00:00
|
|
|
# Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
class BackgroundJobSearchIndex
|
|
|
|
def initialize(object, o_id)
|
|
|
|
@object = object
|
|
|
|
@o_id = o_id
|
|
|
|
end
|
|
|
|
|
|
|
|
def perform
|
|
|
|
record = @object.constantize.lookup(id: @o_id)
|
|
|
|
return if !exists?(record)
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2017-01-31 17:13:45 +00:00
|
|
|
record.search_index_update_backend
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def exists?(record)
|
|
|
|
return true if record
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2017-01-31 17:13:45 +00:00
|
|
|
Rails.logger.info "Can't index #{@object}.lookup(id: #{@o_id}), no such record found"
|
|
|
|
false
|
|
|
|
end
|
|
|
|
end
|