Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattab <matthieu.aubry@gmail.com>2014-01-20 08:50:00 +0400
committermattab <matthieu.aubry@gmail.com>2014-01-20 08:50:00 +0400
commit39dfcad45ff103dcf827843f74e2188a858b1cce (patch)
treecc3ff474c327724260922d2441848c8840773d85 /plugins
parent008bae4fca2d7e82a1f16f80977a43896e985c3e (diff)
Fix test on Mysqli that latitude / longitude are not rounded the same as PDO Mysql
Diffstat (limited to 'plugins')
-rw-r--r--plugins/API/API.php33
1 files changed, 26 insertions, 7 deletions
diff --git a/plugins/API/API.php b/plugins/API/API.php
index 24a96d6aaa..d0075ac3bc 100644
--- a/plugins/API/API.php
+++ b/plugins/API/API.php
@@ -613,17 +613,12 @@ class API extends \Piwik\Plugin\API
$valuesBis = $table->getColumnsStartingWith($segmentName . ColumnDelete::APPEND_TO_COLUMN_NAME_TO_KEEP);
$values = array_merge($values, $valuesBis);
- // remove false values (while keeping zeros)
- $values = array_filter($values, 'strlen');
+ $values = $this->getMostFrequentValues($values);
- // we have a list of all values. let's show the most frequently used first.
- $values = array_count_values($values);
- arsort($values);
- $values = array_keys($values);
+ $values = array_slice($values, 0, $maxSuggestionsToReturn);
$values = array_map(array('Piwik\Common', 'unsanitizeInputValue'), $values);
- $values = array_slice($values, 0, $maxSuggestionsToReturn);
return $values;
}
@@ -642,6 +637,30 @@ class API extends \Piwik\Plugin\API
$doesSegmentNeedActionsInfo = in_array($segmentName, $segmentsNeedActionsInfo) || $isCustomVariablePage || $isEventSegment;
return $doesSegmentNeedActionsInfo;
}
+
+ /**
+ * @param $values
+ * @param $value
+ * @return array
+ */
+ private function getMostFrequentValues($values)
+ {
+ // remove false values (while keeping zeros)
+ $values = array_filter($values, 'strlen');
+
+ // array_count_values requires strings or integer, convert floats to string (mysqli)
+ foreach ($values as &$value) {
+ if (is_numeric($value)) {
+ $value = (string)round($value, 3);
+ }
+ }
+ // we have a list of all values. let's show the most frequently used first.
+ $values = array_count_values($values);
+
+ arsort($values);
+ $values = array_keys($values);
+ return $values;
+ }
}
/**