Class: ThinkingSphinx::RealTime::Populator

Inherits:
Object
  • Object
show all
Defined in:
lib/thinking_sphinx/real_time/populator.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(index) ⇒ Populator

Returns a new instance of Populator.



8
9
10
11
# File 'lib/thinking_sphinx/real_time/populator.rb', line 8

def initialize(index)
  @index = index
  @started_at = Time.current
end

Class Method Details

.populate(index) ⇒ Object



4
5
6
# File 'lib/thinking_sphinx/real_time/populator.rb', line 4

def self.populate(index)
  new(index).populate
end

Instance Method Details

#populateObject



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/thinking_sphinx/real_time/populator.rb', line 13

def populate
  instrument 'start_populating'

  scope.find_in_batches(:batch_size => batch_size) do |instances|
    transcriber.copy *instances
    instrument 'populated', :instances => instances
  end

  transcriber.clear_before(started_at) if configuration.settings["real_time_tidy"]

  instrument 'finish_populating'
end