diff options
Diffstat (limited to 'plugins/CustomDimensions/Dao/AutoSuggest.php')
m--------- | plugins/CustomDimensions | 0 | ||||
-rw-r--r-- | plugins/CustomDimensions/Dao/AutoSuggest.php | 53 |
2 files changed, 53 insertions, 0 deletions
diff --git a/plugins/CustomDimensions b/plugins/CustomDimensions deleted file mode 160000 -Subproject 318661a2fb1ef3b3e5d6d999ae8b9628cb5a113 diff --git a/plugins/CustomDimensions/Dao/AutoSuggest.php b/plugins/CustomDimensions/Dao/AutoSuggest.php new file mode 100644 index 0000000000..6b6c35c3b5 --- /dev/null +++ b/plugins/CustomDimensions/Dao/AutoSuggest.php @@ -0,0 +1,53 @@ +<?php +/** + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * + */ + +namespace Piwik\Plugins\CustomDimensions\Dao; + +use Piwik\API\Request; +use Piwik\Common; +use Piwik\DataTable; +use Piwik\Date; +use Piwik\Db; +use Piwik\Plugins\CustomDimensions\Archiver; + +class AutoSuggest +{ + + /** + * @param array $dimension + * @param int $idSite + * @param int $maxValuesToReturn + * @return array + */ + public function getMostUsedActionDimensionValues($dimension, $idSite, $maxValuesToReturn) + { + // we use first day from the month so it only needs to aggregate archives of two/three months and no weeks etc + $date = Date::now()->subMonth(2)->setDay(1)->toString() . ',today'; + /** @var DataTable $report */ + $report = Request::processRequest('CustomDimensions.getCustomDimension', array( + 'idDimension' => $dimension['idcustomdimension'], + 'idSite' => $idSite, + 'filter_offset' => 0, + 'filter_limit' => $maxValuesToReturn, + 'period' => 'range', + 'date' => $date, + 'disable_queued_filters' => 1 + ), array()); + + $labels = $report->getColumn('label'); + $notDefinedKey = array_search(Archiver::LABEL_CUSTOM_VALUE_NOT_DEFINED, $labels); + if ($notDefinedKey !== false) { + unset($labels[$notDefinedKey]); + $labels = array_values($labels); + } + + return $labels; + } + +}
\ No newline at end of file |