You are here

public function HelpSearch::indexStatus in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/help_topics/src/Plugin/Search/HelpSearch.php \Drupal\help_topics\Plugin\Search\HelpSearch::indexStatus()
  2. 10 core/modules/help_topics/src/Plugin/Search/HelpSearch.php \Drupal\help_topics\Plugin\Search\HelpSearch::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

core/modules/help_topics/src/Plugin/Search/HelpSearch.php, line 466

Class

HelpSearch
Handles searching for help using the Search module index.

Namespace

Drupal\help_topics\Plugin\Search

Code

public function indexStatus() {
  $this
    ->updateTopicList();
  $total = $this->database
    ->select('help_search_items', 'hsi')
    ->countQuery()
    ->execute()
    ->fetchField();
  $query = $this->database
    ->select('help_search_items', 'hsi');
  $query
    ->addExpression('COUNT(DISTINCT([hsi].[sid]))');
  $query
    ->leftJoin('search_dataset', 'sd', '[hsi].[sid] = [sd].[sid] AND [sd].[type] = :type', [
    ':type' => $this
      ->getType(),
  ]);
  $condition = $this->database
    ->condition('OR');
  $condition
    ->condition('sd.reindex', 0, '<>')
    ->isNull('sd.sid');
  $query
    ->condition($condition);
  $remaining = $query
    ->execute()
    ->fetchField();
  return [
    'remaining' => $remaining,
    'total' => $total,
  ];
}