From d3ec33b2b885b484bf536e1440fbe9b8ca314c49 Mon Sep 17 00:00:00 2001 From: Vadym Honcharuk Date: Mon, 13 Jan 2025 19:49:43 +0200 Subject: [PATCH] [Core] Feature #3432, code refactoring --- .../Api/Healthcheck/CheckInterface.php | 5 +++++ .../Model/Healthcheck/ReplicasConfigCheck.php | 4 +--- .../Model/Healthcheck/ShardsConfigCheck.php | 4 +--- .../Model/System/Message/GenericHealthcheckWarning.php | 5 ++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/module-elasticsuite-core/Api/Healthcheck/CheckInterface.php b/src/module-elasticsuite-core/Api/Healthcheck/CheckInterface.php index b1194c760..658b5b906 100644 --- a/src/module-elasticsuite-core/Api/Healthcheck/CheckInterface.php +++ b/src/module-elasticsuite-core/Api/Healthcheck/CheckInterface.php @@ -19,6 +19,11 @@ */ interface CheckInterface { + /** + * Warning status declaration. + */ + const WARNING_STATUS = 'warning'; + /** * Retrieve the unique identifier for the health check. * diff --git a/src/module-elasticsuite-core/Model/Healthcheck/ReplicasConfigCheck.php b/src/module-elasticsuite-core/Model/Healthcheck/ReplicasConfigCheck.php index 383c04d32..344d9aa9b 100644 --- a/src/module-elasticsuite-core/Model/Healthcheck/ReplicasConfigCheck.php +++ b/src/module-elasticsuite-core/Model/Healthcheck/ReplicasConfigCheck.php @@ -41,8 +41,6 @@ class ReplicasConfigCheck implements CheckInterface */ private const ES_INDICES_SETTINGS_WIKI_PAGE = 'https://github.com/Smile-SA/elasticsuite/wiki/ModuleInstall#indices-settings'; - public const WARNING_STATUS = 'warning'; - /** * @var IndexSettingsHelper */ @@ -94,7 +92,7 @@ public function getDescription(): string { $status = $this->getStatus(); - if ($status === self::WARNING_STATUS) { + if ($status === CheckInterface::WARNING_STATUS) { // Description when the replicas configuration is incorrect. // @codingStandardsIgnoreStart return __( diff --git a/src/module-elasticsuite-core/Model/Healthcheck/ShardsConfigCheck.php b/src/module-elasticsuite-core/Model/Healthcheck/ShardsConfigCheck.php index a1c237789..ecc4bf6a3 100644 --- a/src/module-elasticsuite-core/Model/Healthcheck/ShardsConfigCheck.php +++ b/src/module-elasticsuite-core/Model/Healthcheck/ShardsConfigCheck.php @@ -42,8 +42,6 @@ class ShardsConfigCheck implements CheckInterface */ private const ES_INDICES_SETTINGS_WIKI_PAGE = 'https://github.com/Smile-SA/elasticsuite/wiki/ModuleInstall#indices-settings'; - public const WARNING_STATUS = 'warning'; - public const UNDEFINED_SIZE = 'N/A'; /** @@ -100,7 +98,7 @@ public function getDescription(): string $maxIndexSize = $this->getMaxIndexSize(); $status = $this->getStatus(); - if ($status === self::WARNING_STATUS) { + if ($status === CheckInterface::WARNING_STATUS) { // Description when the shard's configuration is incorrect. // @codingStandardsIgnoreStart return __( diff --git a/src/module-elasticsuite-core/Model/System/Message/GenericHealthcheckWarning.php b/src/module-elasticsuite-core/Model/System/Message/GenericHealthcheckWarning.php index a807adf06..3372ffa0c 100644 --- a/src/module-elasticsuite-core/Model/System/Message/GenericHealthcheckWarning.php +++ b/src/module-elasticsuite-core/Model/System/Message/GenericHealthcheckWarning.php @@ -16,6 +16,7 @@ use Magento\Framework\UrlInterface; use Magento\Framework\Notification\MessageInterface; +use Smile\ElasticsuiteCore\Api\Healthcheck\CheckInterface; use Smile\ElasticsuiteCore\Model\Healthcheck\HealthcheckList; /** @@ -38,8 +39,6 @@ class GenericHealthcheckWarning implements MessageInterface */ private $urlBuilder; - public const WARNING_STATUS = 'warning'; - /** * Constructor. * @@ -105,7 +104,7 @@ private function getIssueCount(): int $issuesCount = 0; foreach ($this->healthcheckList->getChecks() as $check) { - if ($check->getStatus() === self::WARNING_STATUS) { + if ($check->getStatus() === CheckInterface::WARNING_STATUS) { $issuesCount++; } }