Skip to content

Commit 8e33ee0

Browse files
committed
feat: ruby
1 parent 5e9c816 commit 8e33ee0

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

templates/ruby/search_helpers.mustache

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,16 +209,17 @@ end
209209
#
210210
# @param index_name [String]: The `index_name` to save `objects` in.
211211
# @param objects [Array]: The array of `objects` to store in the given Algolia `indexName`.
212+
# @param wait_for_tasks [Boolean]: Whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable.
212213
# @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
213214
#
214215
# @return [BatchResponse]
215216
#
216-
def save_objects(index_name, objects, request_options = {})
217+
def save_objects(index_name, objects, wait_for_tasks = false, request_options = {})
217218
chunked_batch(
218219
index_name,
219220
objects,
220221
Search::Action::ADD_OBJECT,
221-
false,
222+
wait_for_tasks,
222223
1000,
223224
request_options
224225
)
@@ -228,16 +229,17 @@ end
228229
#
229230
# @param index_name [String]: The `index_name` to delete `object_ids` from.
230231
# @param object_ids [Array]: The object_ids to delete.
232+
# @param wait_for_tasks [Boolean]: Whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable.
231233
# @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
232234
#
233235
# @return [BatchResponse]
234236
#
235-
def delete_objects(index_name, object_ids, request_options = {})
237+
def delete_objects(index_name, object_ids, wait_for_tasks = false, request_options = {})
236238
chunked_batch(
237239
index_name,
238240
object_ids.map { |id| { "objectID" => id } },
239241
Search::Action::DELETE_OBJECT,
240-
false,
242+
wait_for_tasks,
241243
1000,
242244
request_options
243245
)

0 commit comments

Comments
 (0)