lib/thinking_sphinx/deltas/resque_delta/tasks.rb in ts-resque-delta-1.1.4 vs lib/thinking_sphinx/deltas/resque_delta/tasks.rb in ts-resque-delta-1.1.5

- old
+ new

@@ -1,40 +1,40 @@ require 'thinking_sphinx/deltas/resque_delta' namespace :thinking_sphinx do # Return a list of index prefixes (i.e. without "_core"/"_delta"). - def sphinx_indexes - unless @sphinx_indexes + def sphinx_indices + unless @sphinx_indices @ts_config ||= ThinkingSphinx::Configuration.instance @ts_config.generate - @sphinx_indexes = @ts_config.configuration.indexes.collect { |i| i.name } - # The collected indexes look like: + @sphinx_indices = @ts_config.configuration.indices.collect { |i| i.name } + # The collected indices look like: # ["foo_core", "foo_delta", "foo", "bar_core", "bar_delta", "bar"] - @sphinx_indexes.reject! { |i| i =~ /_(core|delta)$/} + @sphinx_indices.reject! { |i| i =~ /_(core|delta)$/} # Now we have: # ["foo", "bar"] end - @sphinx_indexes + @sphinx_indices end def lock_delta(index_name) ThinkingSphinx::Deltas::ResqueDelta.lock("#{index_name}_delta") end def unlock_delta(index_name) ThinkingSphinx::Deltas::ResqueDelta.unlock("#{index_name}_delta") end - desc 'Lock all delta indexes (Resque will not run indexer or place new jobs on the :ts_delta queue).' + desc 'Lock all delta indices (Resque will not run indexer or place new jobs on the :ts_delta queue).' task :lock_deltas do - sphinx_indexes.each { |index_name| lock_delta(index_name) } + sphinx_indices.each { |index_name| lock_delta(index_name) } end - desc 'Unlock all delta indexes.' + desc 'Unlock all delta indices.' task :unlock_deltas do - sphinx_indexes.each { |index_name| unlock_delta(index_name) } + sphinx_indices.each { |index_name| unlock_delta(index_name) } end desc 'Like `rake thinking_sphinx:index`, but locks one index at a time.' task :smart_index => :app_env do # Load config like ts:in. @@ -44,10 +44,10 @@ @ts_config.build end FileUtils.mkdir_p(@ts_config.searchd_file_path) # Index each core, one at a time. Wrap with delta locking logic. - sphinx_indexes.each do |index_name| + sphinx_indices.each do |index_name| lock_delta(index_name) @ts_config.controller.index("#{index_name}_core", :verbose => true) ret = $? unlock_delta(index_name) exit(-1) if ret.to_i != 0