diff options
author | Matthieu Napoli <matthieu@mnapoli.fr> | 2015-03-18 08:55:51 +0300 |
---|---|---|
committer | Matthieu Napoli <matthieu@mnapoli.fr> | 2015-03-18 08:55:51 +0300 |
commit | 56b84e4230b9b068fd898e08e350e7e58be9065b (patch) | |
tree | 30ec93c4951f4da0811b404229e71dd15b96a73d | |
parent | 7e7af189d121d7d4680ad77fc66dc62d83ba5676 (diff) | |
parent | 558877dc93ab4ca99528e1fc8cab7ed7c8b6257a (diff) |
Merge branch 'master' of github.com:piwik/piwik
-rw-r--r-- | core/DataTable/Filter/RangeCheck.php | 13 | ||||
-rw-r--r-- | core/Plugin/Visualization.php | 4 | ||||
-rw-r--r-- | core/Version.php | 2 | ||||
-rw-r--r-- | js/piwik.js | 1 | ||||
-rw-r--r-- | plugins/DevicePlugins/API.php | 22 | ||||
-rw-r--r-- | tests/PHPUnit/Unit/DataTable/Filter/RangeCheckTest.php | 27 |
6 files changed, 60 insertions, 9 deletions
diff --git a/core/DataTable/Filter/RangeCheck.php b/core/DataTable/Filter/RangeCheck.php index ab144e6b4a..211638d3ca 100644 --- a/core/DataTable/Filter/RangeCheck.php +++ b/core/DataTable/Filter/RangeCheck.php @@ -47,6 +47,19 @@ class RangeCheck extends BaseFilter { foreach ($table->getRows() as $row) { $value = $row->getColumn($this->columnToFilter); + + if ($value === false) { + $value = $row->getMetadata($this->columnToFilter); + if ($value !== false) { + if ($value < (float) self::$minimumValue) { + $row->setMetadata($this->columnToFilter, self::$minimumValue); + } elseif ($value > (float) self::$maximumValue) { + $row->setMetadata($this->columnToFilter, self::$maximumValue); + } + } + continue; + } + if ($value !== false) { if ($value < (float) self::$minimumValue) { $row->setColumn($this->columnToFilter, self::$minimumValue); diff --git a/core/Plugin/Visualization.php b/core/Plugin/Visualization.php index 3d48c24d15..6e6b4802a0 100644 --- a/core/Plugin/Visualization.php +++ b/core/Plugin/Visualization.php @@ -399,6 +399,8 @@ class Visualization extends ViewDataTable $postProcessor->setCallbackBeforeGenericFilters(function (DataTable\DataTableInterface $dataTable) use ($self, $postProcessor) { + $self->setDataTable($dataTable); + // First, filters that delete rows foreach ($self->config->getPriorityFilters() as $filter) { $dataTable->filter($filter[0], $filter[1]); @@ -417,6 +419,8 @@ class Visualization extends ViewDataTable $postProcessor->setCallbackAfterGenericFilters(function (DataTable\DataTableInterface $dataTable) use ($self) { + $self->setDataTable($dataTable); + $self->afterGenericFiltersAreAppliedToLoadedDataTable(); // queue other filters so they can be applied later if queued filters are disabled diff --git a/core/Version.php b/core/Version.php index a0b103340e..d937eaafdd 100644 --- a/core/Version.php +++ b/core/Version.php @@ -20,7 +20,7 @@ final class Version * The current Piwik version. * @var string */ - const VERSION = '2.12.0-b7'; + const VERSION = '2.12.0-b8'; public function isStableVersion($version) { diff --git a/js/piwik.js b/js/piwik.js index cac08102f5..9305b4e548 100644 --- a/js/piwik.js +++ b/js/piwik.js @@ -3993,6 +3993,7 @@ if (typeof Piwik !== 'object') { }, devicePixelRatio = (new RegExp('Mac OS X.*Safari/')).test(navigatorAlias.userAgent) ? windowAlias.devicePixelRatio || 1 : 1; + // detect browser features except IE < 11 (IE 11 user agent is no longer MSIE) if (!((new RegExp('MSIE')).test(navigatorAlias.userAgent))) { // general plugin detection if (navigatorAlias.mimeTypes && navigatorAlias.mimeTypes.length) { diff --git a/plugins/DevicePlugins/API.php b/plugins/DevicePlugins/API.php index 21765a981d..b4b33b8db3 100644 --- a/plugins/DevicePlugins/API.php +++ b/plugins/DevicePlugins/API.php @@ -41,18 +41,18 @@ class API extends \Piwik\Plugin\API { // fetch all archive data required $dataTable = $this->getDataTable(Archiver::PLUGIN_RECORD_NAME, $idSite, $period, $date, $segment); - $browserTypes = $this->getDataTable(DDArchiver::BROWSER_ENGINE_RECORD_NAME, $idSite, $period, $date, $segment); + $browserVersions = $this->getDataTable(DDArchiver::BROWSER_VERSION_RECORD_NAME, $idSite, $period, $date, $segment); $archive = Archive::build($idSite, $period, $date, $segment); $visitsSums = $archive->getDataTableFromNumeric('nb_visits'); // check whether given tables are arrays if ($dataTable instanceof DataTable\Map) { $dataTableMap = $dataTable->getDataTables(); - $browserTypesArray = $browserTypes->getDataTables(); + $browserVersionsArray = $browserVersions->getDataTables(); $visitSumsArray = $visitsSums->getDataTables(); } else { $dataTableMap = array($dataTable); - $browserTypesArray = array($browserTypes); + $browserVersionsArray = array($browserVersions); $visitSumsArray = array($visitsSums); } @@ -61,9 +61,18 @@ class API extends \Piwik\Plugin\API // Calculate percentage, but ignore IE users because plugin detection doesn't work on IE $ieVisits = 0; - $ieStats = $browserTypesArray[$key]->getRowFromLabel('Trident'); - if ($ieStats !== false) { - $ieVisits = $ieStats->getColumn(Metrics::INDEX_NB_VISITS); + $browserVersionsToExclude = array( + 'IE;10.0', + 'IE;9.0', + 'IE;8.0', + 'IE;7.0', + 'IE;6.0', + ); + foreach ($browserVersionsToExclude as $browserVersionToExclude) { + $ieStats = $browserVersionsArray[$key]->getRowFromLabel($browserVersionToExclude); + if ($ieStats !== false) { + $ieVisits += $ieStats->getColumn(Metrics::INDEX_NB_VISITS); + } } // get according visitsSum @@ -83,6 +92,7 @@ class API extends \Piwik\Plugin\API $dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getPluginsLogo')); $dataTable->queueFilter('ColumnCallbackReplace', array('label', 'ucfirst')); + $dataTable->queueFilter('RangeCheck', array('nb_visits_percentage', 0, 1)); return $dataTable; } diff --git a/tests/PHPUnit/Unit/DataTable/Filter/RangeCheckTest.php b/tests/PHPUnit/Unit/DataTable/Filter/RangeCheckTest.php index 0deccd217f..4002424436 100644 --- a/tests/PHPUnit/Unit/DataTable/Filter/RangeCheckTest.php +++ b/tests/PHPUnit/Unit/DataTable/Filter/RangeCheckTest.php @@ -11,13 +11,13 @@ namespace Piwik\Tests\Unit\DataTable\Filter; use Piwik\DataTable\Filter\RangeCheck; use Piwik\DataTable; use Piwik\DataTable\Row; +use Piwik\Plugins\CoreHome\Columns\Metrics\VisitsPercent; /** * @group DataTableTest */ class DataTable_Filter_RangeCheckTest extends \PHPUnit_Framework_TestCase { - public function testRangeCheckNormalDataTable() { $table = new DataTable(); @@ -35,7 +35,6 @@ class DataTable_Filter_RangeCheckTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expectedOrder, $table->getColumn('count')); } - public function testRangeCheckNormalDataTableNonIntegerValues() { $table = new DataTable(); @@ -53,4 +52,28 @@ class DataTable_Filter_RangeCheckTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expectedOrder, $table->getColumn('count')); } + + public function testRangeCheckOnMetadata() + { + $table = new DataTable(); + $table->addRowsFromArray(array( + array( + Row::COLUMNS => array('label' => 'foo'), + Row::METADATA => array('count' => 5), + ), + array( + Row::COLUMNS => array('label' => 'bar'), + Row::METADATA => array('count' => 10), + ), + array( + Row::COLUMNS => array('label' => 'bar'), + Row::METADATA => array('count' => 15), + ), + )); + + $filter = new RangeCheck($table, 'count', 0, 10); + $filter->filter($table); + + $this->assertEquals(array(5, 10, 10), $table->getRowsMetadata('count')); + } } |