Class: ThinkingSphinx::Deltas::DelayedDelta
- Inherits:
-
DefaultDelta
- Object
- DefaultDelta
- ThinkingSphinx::Deltas::DelayedDelta
show all
- Includes:
- Binary, SphinxQL
- Defined in:
- lib/thinking_sphinx/deltas/delayed_delta.rb
Overview
Delayed Deltas for Thinking Sphinx, using Delayed Job.
This documentation is aimed at those reading the code. If you’re looking for a guide to Thinking Sphinx and/or deltas, I recommend you start with the Thinking Sphinx site instead - or the README for this library at the very least.
Defined Under Namespace
Modules: Binary, SphinxQL
Class Method Summary
collapse
Methods included from SphinxQL
#delete, #index
Methods included from Binary
#index
Class Method Details
.cancel_jobs ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/thinking_sphinx/deltas/delayed_delta.rb', line 17
def self.cancel_jobs
where_clause = [
"handler LIKE (?) AND locked_at IS NULL AND locked_by IS NULL AND failed_at IS NULL", "--- !ruby/object:ThinkingSphinx::Deltas::%"
]
if Delayed::Job.respond_to?(:where)
Delayed::Job.where(where_clause).delete_all
else
Delayed::Job.delete_all(where_clause)
end
end
|
.enqueue_unless_duplicates(object) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/thinking_sphinx/deltas/delayed_delta.rb', line 30
def self.enqueue_unless_duplicates(object)
if Delayed::Job.respond_to?(:where)
return if Delayed::Job.where(
:handler => object.to_yaml, :locked_at => nil, :failed_at => nil
).count > 0
else
return if Delayed::Job.count(
:conditions => {:handler => object.to_yaml, :locked_at => nil, :failed_at => nil}
) > 0
end
Delayed::Job.enqueue object, job_options
end
|
.job_option(setting, default = nil) ⇒ Object
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/thinking_sphinx/deltas/delayed_delta.rb', line 57
def self.job_option(setting, default = nil)
configuration = ThinkingSphinx::Configuration.instance
if configuration.respond_to? setting
configuration.send(setting)
elsif configuration.respond_to? :settings
configuration.settings[setting.to_s] || default
else
default
end
end
|
.job_options ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/thinking_sphinx/deltas/delayed_delta.rb', line 44
def self.job_options
if Gem.loaded_specs['delayed_job'].version.to_s.match(/^2\.0\./)
ThinkingSphinx::Configuration.instance.delayed_job_priority || 0
else
{
:priority => job_option(:delayed_job_priority, 0),
:queue => job_option(:delayed_job_queue)
}
end
end
|