diff options
author | Ben Burgess <88810029+bx80@users.noreply.github.com> | 2021-11-19 13:39:19 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-19 13:39:19 +0300 |
commit | b426c7b71aca9a4f77d6e676f1bd5fb9decbd5b0 (patch) | |
tree | 466c3d946b61dbabc4c31378a2ac6fc4199cc2f7 /plugins/UserCountry | |
parent | a36eb5bdf9834fc40cbe1a992f7a230bd90f3b9b (diff) |
Sort segment static lists by usage (#18321)
* Sort segment static lists by usage for countryCode, browserName and operatingSystemName
* Test fixes and updates
* Count unknown list values and only include unknown if enough visits
* Added segment property to indicate if most frequent values are required
* Remove new segment needsMostFrequentValues implementation value from final API output
Diffstat (limited to 'plugins/UserCountry')
-rw-r--r-- | plugins/UserCountry/Columns/Country.php | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/plugins/UserCountry/Columns/Country.php b/plugins/UserCountry/Columns/Country.php index 1f8544ae6e..9a13f68790 100644 --- a/plugins/UserCountry/Columns/Country.php +++ b/plugins/UserCountry/Columns/Country.php @@ -50,6 +50,7 @@ class Country extends Base $segment->setSegment('countryName'); $segment->setName('UserCountry_Country'); $segment->setAcceptedValues('Germany, France, Spain, ...'); + $segment->setNeedsMostFrequentValues(false); $regionDataProvider = StaticContainer::get('Piwik\Intl\Data\Provider\RegionDataProvider'); $countryList = $regionDataProvider->getCountryList(); array_walk($countryList, function(&$item, $key) { @@ -63,8 +64,8 @@ class Country extends Base } return $result; }); - $segment->setSuggestedValuesCallback(function ($idSite, $maxValuesToReturn) use ($countryList) { - return array_values($countryList + ['Unknown']); + $segment->setSuggestedValuesCallback(function ($idSite, $maxValuesToReturn, $table) use ($countryList) { + return $this->sortStaticListByUsage($countryList, $table, 'countryCode', $maxValuesToReturn); }); $segmentsList->addSegment($dimensionSegmentFactory->createSegment($segment)); } |