diff options
author | matt <matt@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2009-03-30 06:22:03 +0400 |
---|---|---|
committer | matt <matt@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2009-03-30 06:22:03 +0400 |
commit | 241cd5c015c46945140be70c7daec15e166de29c (patch) | |
tree | 6c7740e8e5dffaa4006b9208324a1952bac49469 /plugins/UserCountry | |
parent | 7b3d0025c861bff8d9230faafae5d6ffff8f912c (diff) |
- fixing recently introduced sorting issue, refactoring, cleaning up the generic filters concept by removing the automatic sorting of data
- fixing issue when executing unit tests would invalidate tmp/cache/tracker files
- fixed edge case issue when calling several apis from one http request, and requesting recursive output, it was failing in some random cases
- adding a unit test that calls all callable api methods and check for non empty output
-
Diffstat (limited to 'plugins/UserCountry')
-rw-r--r-- | plugins/UserCountry/API.php | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/plugins/UserCountry/API.php b/plugins/UserCountry/API.php index f0722307e5..70f404608a 100644 --- a/plugins/UserCountry/API.php +++ b/plugins/UserCountry/API.php @@ -30,30 +30,35 @@ class Piwik_UserCountry_API public function getCountry( $idSite, $period, $date ) { - Piwik::checkUserHasViewAccess( $idSite ); - $archive = Piwik_Archive::build($idSite, $period, $date ); - $dataTable = $archive->getDataTable('UserCountry_country'); + $dataTable = $this->getDataTable('UserCountry_country', $idSite, $period, $date); + // apply filter on the whole datatable in order the inline search to work (searches are done on "beautiful" label) $filter = new Piwik_DataTable_Filter_ColumnCallbackAddMetadata($dataTable, 'label', 'code', create_function('$label', 'return $label;')); $filter = new Piwik_DataTable_Filter_ColumnCallbackAddMetadata($dataTable, 'label', 'logo', 'Piwik_getFlagFromCode'); $filter = new Piwik_DataTable_Filter_ColumnCallbackReplace($dataTable, 'label', 'Piwik_CountryTranslate'); - $dataTable->queueFilter('Piwik_DataTable_Filter_ReplaceColumnNames'); $dataTable->queueFilter('Piwik_DataTable_Filter_AddConstantMetadata', array('logoWidth', 18)); $dataTable->queueFilter('Piwik_DataTable_Filter_AddConstantMetadata', array('logoHeight', 12)); return $dataTable; } + public function getContinent( $idSite, $period, $date ) { - Piwik::checkUserHasViewAccess( $idSite ); - $archive = Piwik_Archive::build($idSite, $period, $date ); - $dataTable = $archive->getDataTable('UserCountry_continent'); + $dataTable = $this->getDataTable('UserCountry_continent', $idSite, $period, $date); $dataTable->queueFilter('Piwik_DataTable_Filter_ColumnCallbackAddMetadata', array('label', 'code', create_function('$label', 'return $label;'))); $dataTable->queueFilter('Piwik_DataTable_Filter_ColumnCallbackReplace', array('label', 'Piwik_ContinentTranslate')); - $dataTable->queueFilter('Piwik_DataTable_Filter_ReplaceColumnNames'); return $dataTable; } + protected function getDataTable($name, $idSite, $period, $date) + { + Piwik::checkUserHasViewAccess( $idSite ); + $archive = Piwik_Archive::build($idSite, $period, $date ); + $dataTable = $archive->getDataTable($name); + $filter = new Piwik_DataTable_Filter_Sort($dataTable, Piwik_Archive::INDEX_NB_VISITS); + $dataTable->queueFilter('Piwik_DataTable_Filter_ReplaceColumnNames'); + return $dataTable; + } - function getNumberOfDistinctCountries($idSite, $period, $date) + public function getNumberOfDistinctCountries($idSite, $period, $date) { Piwik::checkUserHasViewAccess( $idSite ); $archive = Piwik_Archive::build($idSite, $period, $date ); |