diff options
author | Stefan Giehl <stefan@matomo.org> | 2019-05-09 23:20:27 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-09 23:20:27 +0300 |
commit | a4c8dc92994ccfd5775d080a4f63cb095ab95e19 (patch) | |
tree | 1dc5f537e9cfeaa9c809d183f3565294c57ac455 /plugins/DevicesDetection | |
parent | 3daba5ce28072930188f8c15c6f8a6eb9bbb46b5 (diff) |
Ensure segment definitions doen't regress (#14372)
Diffstat (limited to 'plugins/DevicesDetection')
-rw-r--r-- | plugins/DevicesDetection/API.php | 2 | ||||
-rw-r--r-- | plugins/DevicesDetection/Columns/BrowserName.php | 34 | ||||
-rw-r--r-- | plugins/DevicesDetection/Columns/Os.php | 34 |
3 files changed, 31 insertions, 39 deletions
diff --git a/plugins/DevicesDetection/API.php b/plugins/DevicesDetection/API.php index 8e4625f75a..667affa57b 100644 --- a/plugins/DevicesDetection/API.php +++ b/plugins/DevicesDetection/API.php @@ -255,7 +255,7 @@ class API extends \Piwik\Plugin\API public function getBrowsers($idSite, $period, $date, $segment = false) { $dataTable = $this->getDataTable('DevicesDetection_browsers', $idSite, $period, $date, $segment); - $dataTable->filter('AddSegmentByLabel', ['browserCode']); + $dataTable->filter('AddSegmentValue'); // handle legacy archives if ($dataTable instanceof DataTable\Map || !$dataTable->getRowsCount()) { diff --git a/plugins/DevicesDetection/Columns/BrowserName.php b/plugins/DevicesDetection/Columns/BrowserName.php index 0c94371316..2b3c205a2f 100644 --- a/plugins/DevicesDetection/Columns/BrowserName.php +++ b/plugins/DevicesDetection/Columns/BrowserName.php @@ -20,15 +20,23 @@ class BrowserName extends Base { protected $columnName = 'config_browser_name'; protected $columnType = 'VARCHAR(10) NULL'; - protected $segmentName = 'browserName'; + protected $segmentName = 'browserCode'; protected $nameSingular = 'DevicesDetection_ColumnBrowser'; protected $namePlural = 'DevicesDetection_Browsers'; - protected $acceptValues = 'FireFox, Internet Explorer, Chrome, Safari, Opera etc.'; + protected $acceptValues = 'FF, IE, CH, SF, OP etc.'; protected $type = self::TYPE_TEXT; - public function __construct() + protected function configureSegments() { - $this->sqlFilterValue = function ($val) { + $segment = new Segment(); + $segment->setName('DevicesDetection_BrowserCode'); + $this->addSegment($segment); + + $segment = new Segment(); + $segment->setSegment('browserName'); + $segment->setName('DevicesDetection_ColumnBrowser'); + $segment->setAcceptedValues('FireFox, Internet Explorer, Chrome, Safari, Opera etc.'); + $segment->setSqlFilterValue(function ($val) { $browsers = Browser::getAvailableBrowsers(); array_map(function($val) { return Common::mb_strtolower($val); @@ -40,22 +48,10 @@ class BrowserName extends Base } return $result; - }; - $this->suggestedValuesCallback = function ($idSite, $maxValuesToReturn) { + }); + $segment->setSuggestedValuesCallback(function ($idSite, $maxValuesToReturn) { return array_values(Browser::getAvailableBrowsers() + ['Unknown']); - }; - } - - protected function configureSegments() - { - parent::configureSegments(); - - $segment = new Segment(); - $segment->setSegment('browserCode'); - $segment->setName('DevicesDetection_BrowserCode'); - $segment->setAcceptedValues('FF, IE, CH, SF, OP etc.'); - $this->suggestedValuesCallback = null; - $this->sqlFilterValue = null; + }); $this->addSegment($segment); } diff --git a/plugins/DevicesDetection/Columns/Os.php b/plugins/DevicesDetection/Columns/Os.php index e3003b46fa..a86928279e 100644 --- a/plugins/DevicesDetection/Columns/Os.php +++ b/plugins/DevicesDetection/Columns/Os.php @@ -22,15 +22,23 @@ class Os extends Base { protected $columnName = 'config_os'; protected $columnType = 'CHAR(3) NULL'; - protected $segmentName = 'operatingSystemName'; + protected $segmentName = 'operatingSystemCode'; protected $nameSingular = 'DevicesDetection_ColumnOperatingSystem'; protected $namePlural = 'DevicesDetection_OperatingSystems'; - protected $acceptValues = 'Windows, Linux, Mac, Android, iOS etc.'; + protected $acceptValues = 'WIN, LIN, MAX, AND, IOS etc.'; protected $type = self::TYPE_TEXT; - public function __construct() + protected function configureSegments() { - $this->sqlFilterValue = function ($val) { + $segment = new Segment(); + $segment->setName('DevicesDetection_OperatingSystemCode'); + $this->addSegment($segment); + + $segment = new Segment(); + $segment->setSegment('operatingSystemName'); + $segment->setName('DevicesDetection_ColumnOperatingSystem'); + $segment->setAcceptedValues('Windows, Linux, Mac, Android, iOS etc.'); + $segment->setSqlFilterValue(function ($val) { $oss = OperatingSystem::getAvailableOperatingSystems(); array_map(function($val) { return Common::mb_strtolower($val); @@ -42,22 +50,10 @@ class Os extends Base } return $result; - }; - $this->suggestedValuesCallback = function ($idSite, $maxValuesToReturn) { + }); + $segment->setSuggestedValuesCallback(function ($idSite, $maxValuesToReturn) { return array_values(OperatingSystem::getAvailableOperatingSystems() + ['Unknown']); - }; - } - - protected function configureSegments() - { - parent::configureSegments(); - - $segment = new Segment(); - $segment->setSegment('operatingSystemCode'); - $segment->setName('DevicesDetection_OperatingSystemCode'); - $segment->setAcceptedValues('WIN, LIN, MAX, AND, IOS etc.'); - $this->suggestedValuesCallback = null; - $this->sqlFilterValue = null; + }); $this->addSegment($segment); } |