From 35f975accb45152dd669e0009237eed3dc6ada2b Mon Sep 17 00:00:00 2001 From: mattab Date: Sat, 20 Apr 2013 21:02:35 +1200 Subject: Fixes #3904: * new segment 'siteSearchKeyword' Fixes #3903, #3905: * adding few fields in the Live API output to accomodate getSuggestedValuesForSegment * renamed other fields for consistency with segment names Fixes #3906: * new API: getSuggestedValuesForSegment which returns top suggested values for a particular segment. It uses the Live.getLastVisitsDetails API to fetch the most recently used values, and will show the most used values first * Adding tests for everything. The test case actually generates data for all segments so that VisitsSummary.get returns some data for each of the 47 segments being tested returns some data. How it works: * generate extended data in fixture * Tests (1) call getSuggestedValuesForSegment for each segment, check there is some data returned for each segment * get the first suggested value from the list, * Tests (2) call VisitsSummary.get with this segment value, eg. countryCode==ru. * I worked this way for all 47 segments until all tests had some data ==> now we know that all segments have been tested and that the auto suggest works for all segments. TDD FTW! --- plugins/UserCountry/UserCountry.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'plugins/UserCountry') diff --git a/plugins/UserCountry/UserCountry.php b/plugins/UserCountry/UserCountry.php index 20d2935248..34003af178 100644 --- a/plugins/UserCountry/UserCountry.php +++ b/plugins/UserCountry/UserCountry.php @@ -164,7 +164,7 @@ class Piwik_UserCountry extends Piwik_Plugin 'type' => 'dimension', 'category' => 'Visit Location', 'name' => Piwik_Translate('UserCountry_Country'), - 'segment' => 'country', + 'segment' => 'countryCode', 'sqlSegment' => 'log_visit.location_country', 'acceptedValues' => 'de, us, fr, in, es, etc.', ); @@ -172,7 +172,7 @@ class Piwik_UserCountry extends Piwik_Plugin 'type' => 'dimension', 'category' => 'Visit Location', 'name' => Piwik_Translate('UserCountry_Continent'), - 'segment' => 'continent', + 'segment' => 'continentCode', 'sqlSegment' => 'log_visit.location_country', 'acceptedValues' => 'eur, asi, amc, amn, ams, afr, ant, oce', 'sqlFilter' => array('Piwik_UserCountry', 'getCountriesForContinent'), @@ -181,7 +181,7 @@ class Piwik_UserCountry extends Piwik_Plugin 'type' => 'dimension', 'category' => 'Visit Location', 'name' => Piwik_Translate('UserCountry_Region'), - 'segment' => 'region', + 'segment' => 'regionCode', 'sqlSegment' => 'log_visit.location_region', 'acceptedValues' => '01 02, OR, P8, etc.
eg. region=A1;country=fr', ); @@ -197,7 +197,7 @@ class Piwik_UserCountry extends Piwik_Plugin 'type' => 'dimension', 'category' => 'Visit Location', 'name' => Piwik_Translate('UserCountry_Latitude'), - 'segment' => 'lat', + 'segment' => 'latitude', 'sqlSegment' => 'log_visit.location_latitude', 'acceptedValues' => '-33.578, 40.830, etc.
You can select visitors within a lat/long range using &segment=lat>X;lat<Y;long>M;long<N.', ); @@ -205,7 +205,7 @@ class Piwik_UserCountry extends Piwik_Plugin 'type' => 'dimension', 'category' => 'Visit Location', 'name' => Piwik_Translate('UserCountry_Longitude'), - 'segment' => 'long', + 'segment' => 'longitude', 'sqlSegment' => 'log_visit.location_longitude', 'acceptedValues' => '-70.664, 14.326, etc.', ); @@ -489,9 +489,8 @@ class Piwik_UserCountry extends Piwik_Plugin */ public static function getCountriesForContinent($continent) { - $continent = strtolower($continent); - $result = array(); + $continent = strtolower($continent); foreach (Piwik_Common::getCountriesList() as $countryCode => $continentCode) { if ($continent == $continentCode) { $result[] = $countryCode; -- cgit v1.2.3