You are here

public function Basic::getTotalItemsCount in Search API 8

Retrieves the total number of items that are being tracked for this index.

Parameters

string|null $datasource_id: (optional) The datasource to filter the total number of items by.

Return value

int The total number of items that are tracked for this index, or for the given datasource on this index.

Overrides TrackerInterface::getTotalItemsCount

File

src/Plugin/search_api/tracker/Basic.php, line 378

Class

Basic
Provides a tracker implementation which uses a FIFO-like processing order.

Namespace

Drupal\search_api\Plugin\search_api\tracker

Code

public function getTotalItemsCount($datasource_id = NULL) {
  try {
    $select = $this
      ->createSelectStatement();
    if ($datasource_id) {
      $select
        ->condition('datasource', $datasource_id);
    }
    return (int) $select
      ->countQuery()
      ->execute()
      ->fetchField();
  } catch (\Exception $e) {
    $this
      ->logException($e);
    return 0;
  }
}