From 899b0c956a6312d31021103dc5e75643339a56f5 Mon Sep 17 00:00:00 2001 From: Roman Parpalak Date: Fri, 22 Sep 2023 01:09:48 +0300 Subject: [PATCH] Added formatting support to the recommendations. --- _include/src/Layout/ContentItem.php | 2 +- _include/src/Recommendation/RecommendationProvider.php | 4 ++-- composer.lock | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/_include/src/Layout/ContentItem.php b/_include/src/Layout/ContentItem.php index 0a81d253..1dd82bba 100644 --- a/_include/src/Layout/ContentItem.php +++ b/_include/src/Layout/ContentItem.php @@ -146,7 +146,7 @@ private function getMatchContext(Block $block): MatchingContext $text = ''; $totalLength = 0; foreach ($this->snippets as $snippet) { - $length = mb_strlen($snippet); + $length = mb_strlen(strip_tags($snippet)); $deltaLength = ($text !== '' ? 1 : 0) + $length; if ($totalLength > $textMaxLength || $totalLength + $deltaLength > $textMaxLength) { break; diff --git a/_include/src/Recommendation/RecommendationProvider.php b/_include/src/Recommendation/RecommendationProvider.php index 2bc1eb64..18ae9747 100644 --- a/_include/src/Recommendation/RecommendationProvider.php +++ b/_include/src/Recommendation/RecommendationProvider.php @@ -120,8 +120,8 @@ private function getCacheKey(ExternalId $externalId): string private function getValueForCache(ExternalId $externalId): array { return [ - $this->pdoStorage->getSimilar($externalId, null, 4, 9) - ?: $this->pdoStorage->getSimilar($externalId, null, 2, 9), + $this->pdoStorage->getSimilar($externalId, true, null, 4, 9) + ?: $this->pdoStorage->getSimilar($externalId, true, null, 2, 9), time() ]; } diff --git a/composer.lock b/composer.lock index aa8bc54e..8d274d3c 100644 --- a/composer.lock +++ b/composer.lock @@ -416,12 +416,12 @@ "source": { "type": "git", "url": "https://github.com/parpalak/rose.git", - "reference": "2f8059caf08dd1d8ea0a9df4dab1a3a3fbbf9381" + "reference": "a7d32c5c61701c8ee52924eb19baaed46637c4dd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/parpalak/rose/zipball/2f8059caf08dd1d8ea0a9df4dab1a3a3fbbf9381", - "reference": "2f8059caf08dd1d8ea0a9df4dab1a3a3fbbf9381", + "url": "https://api.github.com/repos/parpalak/rose/zipball/a7d32c5c61701c8ee52924eb19baaed46637c4dd", + "reference": "a7d32c5c61701c8ee52924eb19baaed46637c4dd", "shasum": "" }, "require": { @@ -460,7 +460,7 @@ "issues": "https://github.com/parpalak/rose/issues", "source": "https://github.com/parpalak/rose/tree/master" }, - "time": "2023-09-20T15:47:16+00:00" + "time": "2023-09-21T22:05:40+00:00" }, { "name": "symfony/cache",