Skip to content

Commit

Permalink
Rename stage to sync
Browse files Browse the repository at this point in the history
  • Loading branch information
pat committed Jul 7, 2024
1 parent 433cbb7 commit 06b719f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/thinking_sphinx/processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def upsert
end

# Will upsert or delete instance into all matching indices based on index scope
def stage
def sync
real_time_indices.each do |index|
found = find_in(index)

Expand Down
14 changes: 7 additions & 7 deletions spec/acceptance/real_time_updates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@

article = Article.last

ThinkingSphinx::Processor.new(model: article.class, id: article.id).stage
ThinkingSphinx::Processor.new(model: article.class, id: article.id).sync

expect(ThinkingSphinx.search('Nice', :indices => ["published_articles_core"])).to include(article)

Article.connection.execute <<~SQL
UPDATE articles SET published = FALSE WHERE title = 'Nice Title';
SQL
ThinkingSphinx::Processor.new(model: article.class, id: article.id).stage
ThinkingSphinx::Processor.new(model: article.class, id: article.id).sync

expect(ThinkingSphinx.search('Nice', :indices => ["published_articles_core"])).to be_empty
end
Expand All @@ -80,35 +80,35 @@
SQL

article = Article.last
ThinkingSphinx::Processor.new(:instance => article).stage
ThinkingSphinx::Processor.new(:instance => article).sync

expect(ThinkingSphinx.search('Nice', :indices => ["published_articles_core"])).to include(article)

Article.connection.execute <<~SQL
DELETE FROM articles where title = 'Nice Title';
SQL

ThinkingSphinx::Processor.new(:instance => article).stage
ThinkingSphinx::Processor.new(:instance => article).sync

expect(ThinkingSphinx.search('Nice', :indices => ["published_articles_core"])).to be_empty
end

it "stages records in real-time index with alternate ids" do
it "syncs records in real-time index with alternate ids" do
Album.connection.execute <<~SQL
INSERT INTO albums (id, name, artist, integer_id)
VALUES ('#{("a".."z").to_a.sample}', 'Sing to the Moon', 'Laura Mvula', #{rand(10000)});
SQL

album = Album.last
ThinkingSphinx::Processor.new(:model => Album, id: album.integer_id).stage
ThinkingSphinx::Processor.new(:model => Album, id: album.integer_id).sync

expect(ThinkingSphinx.search('Laura', :indices => ["album_real_core"])).to include(album)

Article.connection.execute <<~SQL
DELETE FROM albums where id = '#{album.id}';
SQL

ThinkingSphinx::Processor.new(:instance => album).stage
ThinkingSphinx::Processor.new(:instance => album).sync

expect(ThinkingSphinx.search('Laura', :indices => ["album_real_core"])).to be_empty
end
Expand Down

0 comments on commit 06b719f

Please sign in to comment.