Class: XapianDb::IndexWriters::SidekiqWorker
- Inherits:
-
Object
- Object
- XapianDb::IndexWriters::SidekiqWorker
show all
- Extended by:
- Utilities
- Defined in:
- lib/xapian_db/index_writers/sidekiq_worker.rb
Overview
Worker to update the Xapian index; the worker will be called by sidekiq and uses the DirectWriter to do the real work
Constant Summary
collapse
- APPROVED_TASKS =
[:index, :delete_doc, :reindex_class]
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Utilities
assert_valid_keys, camelize, constantize
Class Method Details
.delete_doc(options) ⇒ Object
33
34
35
36
|
# File 'lib/xapian_db/index_writers/sidekiq_worker.rb', line 33
def delete_doc(options)
options = JSON.parse(options)
DirectWriter.delete_doc_with options['xapian_id']
end
|
.index(options) ⇒ Object
26
27
28
29
30
31
|
# File 'lib/xapian_db/index_writers/sidekiq_worker.rb', line 26
def index(options)
options = JSON.parse(options)
klass = constantize options['class']
obj = klass.respond_to?('get') ? klass.get(options['id']) : klass.find(options['id'])
DirectWriter.index obj, true, changed_attrs: options[:changed_attrs]
end
|
22
23
24
|
# File 'lib/xapian_db/index_writers/sidekiq_worker.rb', line 22
def perform(task, options)
send(task, options) if APPROVED_TASKS.include?(task.to_sym)
end
|
.reindex_class(options) ⇒ Object
38
39
40
41
42
|
# File 'lib/xapian_db/index_writers/sidekiq_worker.rb', line 38
def reindex_class(options)
options = JSON.parse(options)
klass = constantize options['class']
DirectWriter.reindex_class klass, :verbose => false
end
|
.set_max_expansion ⇒ Object
Instance Method Details
13
14
15
|
# File 'lib/xapian_db/index_writers/sidekiq_worker.rb', line 13
def perform(task, options)
self.class.send(task, options) if APPROVED_TASKS.include?(task.to_sym)
end
|