You are here

function drush_search_api_status in Search API 7

Same name and namespace in other branches
  1. 8 search_api.drush.inc \drush_search_api_status()

Display index status.

File

./search_api.drush.inc, line 310
Drush commands for SearchAPI.

Code

function drush_search_api_status($index_id = NULL) {
  if (search_api_drush_static(__FUNCTION__)) {
    return;
  }
  $indexes = search_api_drush_get_index($index_id);
  if (empty($indexes)) {
    return;
  }

  // See search_api_index_status()
  $rows = array(
    array(
      dt('Id'),
      dt('Index'),
      dt('% Complete'),
      dt('Indexed'),
      dt('Total'),
    ),
  );
  foreach ($indexes as $index) {
    $status = search_api_index_status($index);
    $complete = $status['total'] > 0 ? 100 * round($status['indexed'] / $status['total'], 3) . '%' : '-';
    $row = array(
      $index->id,
      $index->name,
      $complete,
      $status['indexed'],
      $status['total'],
    );
    $rows[] = $row;
  }
  drush_print_table($rows);
}