![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/framework/Search/Dynamic/Algorithm/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Framework\Search\Dynamic\Algorithm; use Magento\Framework\DB\Ddl\Table; use Magento\Framework\Search\Adapter\OptionsInterface; use Magento\Framework\Search\Dynamic\Algorithm; use Magento\Framework\Search\Dynamic\DataProviderInterface; use Magento\Framework\Search\Request\BucketInterface; class Improved implements AlgorithmInterface { /** * @var Algorithm */ private $algorithm; /** * @var DataProviderInterface */ private $dataProvider; /** * @var OptionsInterface */ private $options; /** * @param DataProviderInterface $dataProvider * @param Algorithm $algorithm * @param OptionsInterface $options */ public function __construct( DataProviderInterface $dataProvider, Algorithm $algorithm, OptionsInterface $options ) { $this->algorithm = $algorithm; $this->dataProvider = $dataProvider; $this->options = $options; } /** * @inheritdoc */ public function getItems( BucketInterface $bucket, array $dimensions, \Magento\Framework\Search\Dynamic\EntityStorage $entityStorage ) { $aggregations = $this->dataProvider->getAggregations($entityStorage); $options = $this->options->get(); if ($aggregations['count'] < $options['interval_division_limit']) { return []; } $this->algorithm->setStatistics( $aggregations['min'], $aggregations['max'], $aggregations['std'], $aggregations['count'] ); $this->algorithm->setLimits($aggregations['min'], $aggregations['max']); $interval = $this->dataProvider->getInterval($bucket, $dimensions, $entityStorage); $data = $this->algorithm->calculateSeparators($interval); $data[0]['from'] = 0; $dataSize = count($data); for ($key = 0; $key < $dataSize; $key++) { if (isset($data[$key + 1])) { $data[$key]['to'] = $data[$key + 1]['from']; } else { $data[$key]['to'] = max($data[$key]['to'], $aggregations['max'] + 0.01); } } return $data; } }