Sha256: 90d7402da740991889c1e577f91f42fe6b5848e005b241e8f377fa231ae825ff

Contents?: true

Size: 915 Bytes

Versions: 3

Compression:

Stored size: 915 Bytes

Contents

class ThinkingSphinx::Interfaces::RealTime
  include ThinkingSphinx::WithOutput

  def initialize(configuration, options, stream = STDOUT)
    super

    configuration.preload_indices

    FileUtils.mkdir_p configuration.indices_location
  end

  def clear
    indices.each do |index|
      index.render
      Dir["#{index.path}.*"].each { |path| FileUtils.rm path }
    end

    path = configuration.searchd.binlog_path
    FileUtils.rm_r(path) if File.exists?(path)
  end

  def index
    return if indices.empty? || !configuration.controller.running?

    indices.each { |index| ThinkingSphinx::RealTime::Populator.populate index }
  end

  private

  def indices
    @indices ||= begin
      indices = configuration.indices.select { |index| index.type == 'rt' }

      if options[:index_filter]
        indices.select! { |index| index.name == options[:index_filter] }
      end

      indices
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
thinking-sphinx-3.4.2 lib/thinking_sphinx/interfaces/real_time.rb
thinking-sphinx-3.4.1 lib/thinking_sphinx/interfaces/real_time.rb
thinking-sphinx-3.4.0 lib/thinking_sphinx/interfaces/real_time.rb