You are here

public function PhotosImageSearch::indexStatus in Album Photos 8.5

Same name and namespace in other branches
  1. 6.0.x src/Plugin/Search/PhotosImageSearch.php \Drupal\photos\Plugin\Search\PhotosImageSearch::indexStatus()

Reports the status of indexing.

The core search module only invokes this method on active module plugins. Implementing modules do not need to check whether they are active when calculating their return values.

Return value

array An associative array with the key-value pairs:

  • remaining: The number of items left to index.
  • total: The total number of items to index.

Overrides SearchIndexingInterface::indexStatus

File

src/Plugin/Search/PhotosImageSearch.php, line 568

Class

PhotosImageSearch
Handles searching for photos_image entities using the Search module index.

Namespace

Drupal\photos\Plugin\Search

Code

public function indexStatus() {
  $total = $this->database
    ->query('SELECT COUNT(*) FROM {photos_image}')
    ->fetchField();
  $remaining = $this->database
    ->query("SELECT COUNT(DISTINCT p.id) FROM {photos_image} p LEFT JOIN {search_dataset} sd ON sd.sid = p.id AND sd.type = :type WHERE sd.sid IS NULL OR sd.reindex <> 0", [
    ':type' => $this
      ->getPluginId(),
  ])
    ->fetchField();
  return [
    'remaining' => $remaining,
    'total' => $total,
  ];
}