Skip to content

Commit

Permalink
Fixes Smile-SA#1865 catch size of the index is unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
androshchuk committed Jul 23, 2020
1 parent c036227 commit eb43423
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/module-elasticsuite-indices/Model/IndexStatsProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,10 @@ public function indexStats($indexName, $alias): array
$indexStats = $this->indicesStats[$indexName];

$data['number_of_documents'] = $indexStats['total']['docs']['count'];
$data['size'] = $this->sizeFormatted($indexStats['total']['store']['size_in_bytes']);
$data['index_status'] = $this->indexStatusProvider->getIndexStatus($indexName, $alias);
if (isset($indexStats['total']['store']['size_in_bytes'])) {
$data['size'] = $this->sizeFormatted((int) $indexStats['total']['store']['size_in_bytes']);
}
} catch (Exception $e) {
$data['index_status'] = IndexStatus::REBUILDING_STATUS;
}
Expand Down Expand Up @@ -152,11 +154,11 @@ private function isElasticSuiteIndex($indexName): bool
/**
* Size formatted.
*
* @param string $bytes Bytes.
* @param int $bytes Bytes.
*
* @return string
*/
private function sizeFormatted($bytes): string
private function sizeFormatted(int $bytes): string
{
if ($bytes > 0) {
$unit = (int) log($bytes, 1024);
Expand All @@ -167,7 +169,7 @@ private function sizeFormatted($bytes): string
}
}

return $bytes;
return 'undefined';
}

/**
Expand Down

0 comments on commit eb43423

Please sign in to comment.