function search_api_server_tasks_count in Search API 7
Return the number of pending tasks.
Parameters
SearchApiServer|null $server: (optional) The server for which tasks should be counted, or NULL to count for all enabled servers.
Return value
int The number of pending tasks for the server, or in total.
4 calls to search_api_server_tasks_count()
- search_api_access_execute_tasks_batch in ./
search_api.module  - Access callback: Checks whether a user can execute pending tasks.
 - search_api_execute_pending_tasks_batch in ./
search_api.module  - Executes pending server tasks as part of a batch operation.
 - search_api_requirements in ./
search_api.install  - Implements hook_requirements().
 - search_api_server_status_form in ./
search_api.admin.inc  - Form constructor for server operations.
 
File
- ./
search_api.module, line 1584  - Provides a flexible framework for implementing search services.
 
Code
function search_api_server_tasks_count(SearchApiServer $server = NULL) {
  $query = db_select('search_api_task', 't')
    ->fields('t');
  if ($server) {
    $query
      ->condition('server_id', $server->machine_name);
  }
  else {
    $query
      ->join('search_api_server', 's', 's.machine_name = t.server_id');
    $query
      ->condition('s.enabled', 1);
  }
  return $query
    ->countQuery()
    ->execute()
    ->fetchField();
}