You are here

function search_api_execute_pending_tasks_batch in Search API 7

Executes pending server tasks as part of a batch operation.

1 string reference to 'search_api_execute_pending_tasks_batch'
search_api_execute_pending_tasks in ./search_api.module
Provides a batch wrapper for search_api_server_tasks_check().

File

./search_api.module, line 1545
Provides a flexible framework for implementing search services.

Code

function search_api_execute_pending_tasks_batch(SearchApiServer $server = NULL, &$context) {
  if (!isset($context['results']['total'])) {
    $context['results']['total'] = search_api_server_tasks_count($server);
  }
  $total = $context['results']['total'];
  search_api_server_tasks_check($server);
  $remaining = search_api_server_tasks_count($server);
  $executed = max($total - $remaining, 0);
  $args['@remaining'] = $remaining;
  $context['message'] = format_plural($executed, 'Successfully executed @count task, @remaining remaining.', 'Successfully executed @count tasks, @remaining remaining.', $args);
  $context['finished'] = $executed / $total;
}