Skip to content

Commit

Permalink
feat(clients): expose waitForTasks to batch helpers [skip-bc] (genera…
Browse files Browse the repository at this point in the history
…ted)

algolia/api-clients-automation#4030

Co-authored-by: algolia-bot <[email protected]>
Co-authored-by: Clément Vannicatte <[email protected]>
  • Loading branch information
algolia-bot and shortcuts committed Oct 28, 2024
1 parent 9201867 commit 4bdfba6
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/algolia/api/search_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3333,16 +3333,17 @@ def get_secured_api_key_remaining_validity(secured_api_key)
#
# @param index_name [String]: The `index_name` to save `objects` in.
# @param objects [Array]: The array of `objects` to store in the given Algolia `indexName`.
# @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.
# @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)
#
# @return [BatchResponse]
#
def save_objects(index_name, objects, request_options = {})
def save_objects(index_name, objects, wait_for_tasks = false, request_options = {})
chunked_batch(
index_name,
objects,
Search::Action::ADD_OBJECT,
false,
wait_for_tasks,
1000,
request_options
)
Expand All @@ -3352,16 +3353,17 @@ def save_objects(index_name, objects, request_options = {})
#
# @param index_name [String]: The `index_name` to delete `object_ids` from.
# @param object_ids [Array]: The object_ids to delete.
# @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.
# @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)
#
# @return [BatchResponse]
#
def delete_objects(index_name, object_ids, request_options = {})
def delete_objects(index_name, object_ids, wait_for_tasks = false, request_options = {})
chunked_batch(
index_name,
object_ids.map { |id| {"objectID" => id} },
Search::Action::DELETE_OBJECT,
false,
wait_for_tasks,
1000,
request_options
)
Expand All @@ -3372,16 +3374,17 @@ def delete_objects(index_name, object_ids, request_options = {})
# @param index_name [String]: The `index_name` to delete `object_ids` from.
# @param objects [Array]: The objects to partially update.
# @param create_if_not_exists [Boolean]: To be provided if non-existing objects are passed, otherwise, the call will fail.
# @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.
# @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)
#
# @return [BatchResponse]
#
def partial_update_objects(index_name, objects, create_if_not_exists, request_options = {})
def partial_update_objects(index_name, objects, create_if_not_exists, wait_for_tasks = false, request_options = {})
chunked_batch(
index_name,
objects,
create_if_not_exists ? Search::Action::PARTIAL_UPDATE_OBJECT : Search::Action::PARTIAL_UPDATE_OBJECT_NO_CREATE,
false,
wait_for_tasks,
1000,
request_options
)
Expand Down

0 comments on commit 4bdfba6

Please sign in to comment.