Skip to content

Commit

Permalink
Bugfix reindex! when all of targeted records are to delete and nothin…
Browse files Browse the repository at this point in the history
…g to save (#452)

* Fixed bug at reindex! when all of targeted records are to delete and nothing to save.

* Updated not to use &. operator.

* Keep the original last_task for future refactoring.
  • Loading branch information
metheglin authored Dec 3, 2024
1 parent f8f599d commit 92e1100
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/algoliasearch-rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,8 @@ def algolia_reindex!(batch_size = AlgoliaSearch::IndexSettings::DEFAULT_BATCH_SI
end
attributes.merge 'objectID' => algolia_object_id_of(o, options)
end
last_task = AlgoliaSearch.client.save_objects(index_name, objects).last.task_id
save_tasks = AlgoliaSearch.client.save_objects(index_name, objects)
last_task = save_tasks.present? ? save_tasks.last.task_id : last_task
end
AlgoliaSearch.client.wait_for_task(index_name, last_task) if last_task and (synchronous || options[:synchronous])
end
Expand Down

0 comments on commit 92e1100

Please sign in to comment.