Skip to content
Extraits de code Groupes Projets
Valider 39dfcad4 rédigé par mattab's avatar mattab
Parcourir les fichiers

Fix test on Mysqli that latitude / longitude are not rounded the same as PDO Mysql

parent 008bae4f
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -613,17 +613,12 @@ class API extends \Piwik\Plugin\API ...@@ -613,17 +613,12 @@ class API extends \Piwik\Plugin\API
$valuesBis = $table->getColumnsStartingWith($segmentName . ColumnDelete::APPEND_TO_COLUMN_NAME_TO_KEEP); $valuesBis = $table->getColumnsStartingWith($segmentName . ColumnDelete::APPEND_TO_COLUMN_NAME_TO_KEEP);
$values = array_merge($values, $valuesBis); $values = array_merge($values, $valuesBis);
// remove false values (while keeping zeros) $values = $this->getMostFrequentValues($values);
$values = array_filter($values, 'strlen');
// we have a list of all values. let's show the most frequently used first. $values = array_slice($values, 0, $maxSuggestionsToReturn);
$values = array_count_values($values);
arsort($values);
$values = array_keys($values);
$values = array_map(array('Piwik\Common', 'unsanitizeInputValue'), $values); $values = array_map(array('Piwik\Common', 'unsanitizeInputValue'), $values);
$values = array_slice($values, 0, $maxSuggestionsToReturn);
return $values; return $values;
} }
...@@ -642,6 +637,30 @@ class API extends \Piwik\Plugin\API ...@@ -642,6 +637,30 @@ class API extends \Piwik\Plugin\API
$doesSegmentNeedActionsInfo = in_array($segmentName, $segmentsNeedActionsInfo) || $isCustomVariablePage || $isEventSegment; $doesSegmentNeedActionsInfo = in_array($segmentName, $segmentsNeedActionsInfo) || $isCustomVariablePage || $isEventSegment;
return $doesSegmentNeedActionsInfo; 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;
}
} }
/** /**
......
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<result> <result>
<row>49.250000</row> <row>49.25</row>
<row>123.456001</row> <row>123.456</row>
<row>47.249001</row> <row>47.249</row>
<row>124.456001</row> <row>124.456</row>
<row>29.650000</row> <row>29.65</row>
<row>1.000000</row> <row>1</row>
</result> </result>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<result> <result>
<row>-123.133003</row> <row>-123.133</row>
<row>21.320999</row> <row>21.321</row>
<row>6.018000</row> <row>6.018</row>
<row>22.231001</row> <row>22.231</row>
<row>91.099998</row> <row>91.1</row>
<row>2.000000</row> <row>2</row>
</result> </result>
\ No newline at end of file
Subproject commit 232dfeb4ac37f347e478e03d28448e5ea6d2f9d7 Subproject commit 63fe6dc64e557c9f5daacd4e274524b92cae39f4
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter