Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsgiehl <stefan@piwik.org>2014-12-08 01:15:35 +0300
committersgiehl <stefan@piwik.org>2014-12-08 01:15:59 +0300
commit4af22dfde7e3901d83b54fbd951a54c05edb3693 (patch)
tree0d4b6559f8d610a0efc8016b619ec8fc6148e824
parent4e2205e95b13f09529d742d58dc0684119e131da (diff)
fix problem in api for fallback to old browser/os archives
-rw-r--r--core/Updates/2.10.0-b5.php (renamed from core/Updates/2.10.0-b1.php)2
-rw-r--r--core/Version.php2
-rw-r--r--plugins/DevicesDetection/API.php101
3 files changed, 35 insertions, 70 deletions
diff --git a/core/Updates/2.10.0-b1.php b/core/Updates/2.10.0-b5.php
index dc7f482b1a..1cbcb0e353 100644
--- a/core/Updates/2.10.0-b1.php
+++ b/core/Updates/2.10.0-b5.php
@@ -40,7 +40,7 @@ use Piwik\Plugins\Dashboard\Model AS DashboardModel;
* contains DevicesDetection data. Day archives will always contain full data, but week/month/year archives may not.
* So we need to recreate those week/month/year archives.
*/
-class Updates_2_10_0_b1 extends Updates
+class Updates_2_10_0_b5 extends Updates
{
static function getSql()
diff --git a/core/Version.php b/core/Version.php
index 0585736f6d..4c3de8b7df 100644
--- a/core/Version.php
+++ b/core/Version.php
@@ -20,5 +20,5 @@ final class Version
* The current Piwik version.
* @var string
*/
- const VERSION = '2.10.0-b4';
+ const VERSION = '2.10.0-b5';
}
diff --git a/plugins/DevicesDetection/API.php b/plugins/DevicesDetection/API.php
index ad7d01d6e7..66fe7eaf28 100644
--- a/plugins/DevicesDetection/API.php
+++ b/plugins/DevicesDetection/API.php
@@ -125,7 +125,10 @@ class API extends \Piwik\Plugin\API
$dataTable = $this->getDataTable('DevicesDetection_os', $idSite, $period, $date, $segment);
// handle legacy archives
- $this->checkForFallbackToOsVersions($dataTable, $idSite, $period, $date, $segment);
+ if ($dataTable instanceof DataTable\Map || !$dataTable->getRowsCount()) {
+ $versionDataTable = $this->getDataTable('DevicesDetection_osVersions', $idSite, $period, $date, $segment);
+ $dataTable = $this->mergeDataTables($dataTable, $versionDataTable);
+ }
$dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\getOSFamilyFullName'));
$dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getOsFamilyLogo'));
@@ -134,7 +137,7 @@ class API extends \Piwik\Plugin\API
/**
- * That methods handles teh fallback to os version datatables to calculate those without versions.
+ * That methods handles the fallback to version datatables to calculate those without versions.
*
* Unlike DevicesDetection plugin now, the UserSettings plugin did not store archives holding the os and browser data without
* their version number. The "version-less" reports were always generated out of the "version-containing" archives .
@@ -144,37 +147,40 @@ class API extends \Piwik\Plugin\API
* them here from the "version-containing" reports if possible.
*
* @param DataTable\DataTableInterface $dataTable
- * @param $idSite
- * @param $period
- * @param $date
- * @param $segment
+ * @param DataTable\DataTableInterface $dataTable2
+ * @return DataTable\DataTableInterface
*/
- protected function checkForFallbackToOsVersions(DataTable\DataTableInterface &$dataTable, $idSite, $period, $date, $segment)
+ protected function mergeDataTables(DataTable\DataTableInterface $dataTable, DataTable\DataTableInterface $dataTable2)
{
if ($dataTable instanceof DataTable\Map) {
$dataTables = $dataTable->getDataTables();
- foreach ($dataTables as $date => &$table) {
- if (!$table->getRowsCount()) {
- $subTable = $this->getDataTable('DevicesDetection_osVersions', $idSite, $period, $date, $segment);
- $subTable->filter('GroupBy', array('label', function ($osWithVersion) {
- if (strpos($osWithVersion, ';')) {
- return substr($osWithVersion, 0, 3);
- }
- return $osWithVersion;
- }));
- $dataTable->addTable($subTable, $date);
+
+ foreach ($dataTables as $label => $table) {
+
+ $versionDataTables = $dataTable2->getDataTables();
+
+ if (!array_key_exists($label, $versionDataTables)) {
+ continue;
}
+ $newDataTable = $this->mergeDataTables($table, $versionDataTables[$label]);
+ $dataTable->addTable($newDataTable, $label);
}
- } else if (!$dataTable->getRowsCount()) {
- $dataTable = $this->getDataTable('DevicesDetection_osVersions', $idSite, $period, $date, $segment);
- $dataTable->filter('GroupBy', array('label', function ($osWithVersion) {
- if (strpos($osWithVersion, ';')) {
- return substr($osWithVersion, 0, 3);
+ } else if (!$dataTable->getRowsCount() && $dataTable2->getRowsCount()) {
+ $dataTable2->filter('GroupBy', array('label', function ($label) {
+ if (preg_match("/(.+) [0-9]+(?:\.[0-9]+)?$/", $label, $matches)) {
+ return $matches[1]; // should match for browsers
+ }
+ if (strpos($label, ';')) {
+ return substr($label, 0, 3); // should match for os
}
- return $osWithVersion;
+ return $label;
}));
+ echo 'replaced';
+ return $dataTable2;
}
+
+ return $dataTable;
}
/**
@@ -222,7 +228,10 @@ class API extends \Piwik\Plugin\API
$dataTable = $this->getDataTable('DevicesDetection_browsers', $idSite, $period, $date, $segment);
// handle legacy archives
- $this->checkForFallbackToBrowserVersions($dataTable, $idSite, $period, $date, $segment);
+ if ($dataTable instanceof DataTable\Map || !$dataTable->getRowsCount()) {
+ $versionDataTable = $this->getDataTable('DevicesDetection_browserVersions', $idSite, $period, $date, $segment);
+ $dataTable = $this->mergeDataTables($dataTable, $versionDataTable);
+ }
$dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\getBrowserName'));
$dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getBrowserFamilyLogo'));
@@ -230,50 +239,6 @@ class API extends \Piwik\Plugin\API
}
/**
- * That methods handles teh fallback to browser version datatables to calculate those without versions.
- *
- * Unlike DevicesDetection plugin now, the UserSettings plugin did not store archives holding the os and browser data without
- * their version number. The "version-less" reports were always generated out of the "version-containing" archives .
- * For big archives (month/year) that ment that some of the data was truncated, due to the datatable entry limit.
- * To avoid that data loss / inaccuracy in the future, DevicesDetection plugin will also store archives without the version.
- * For data archived before DevicesDetection plugin was enabled, those archives do not exist, so we try to calculate
- * them here from the "version-containing" reports if possible.
- *
- * @param DataTable\DataTableInterface $dataTable
- * @param $idSite
- * @param $period
- * @param $date
- * @param $segment
- */
- protected function checkForFallbackToBrowserVersions(DataTable\DataTableInterface &$dataTable, $idSite, $period, $date, $segment)
- {
- if ($dataTable instanceof DataTable\Map) {
- $dataTables = $dataTable->getDataTables();
- foreach ($dataTables as $date => &$table) {
- if (!$table->getRowsCount()) {
- $subTable = $this->getDataTable('DevicesDetection_browserVersions', $idSite, $period, $date, $segment);
- $subTable->filter('GroupBy', array('label', function ($browserWithVersion) {
- if (preg_match("/(.+) [0-9]+(?:\.[0-9]+)?$/", $browserWithVersion, $matches) === 0) {
- return $browserWithVersion;
- }
- return $matches[1];
- }));
- $dataTable->addTable($subTable, $date);
- }
- }
-
- } else if (!$dataTable->getRowsCount()) {
- $dataTable = $this->getDataTable('DevicesDetection_browserVersions', $idSite, $period, $date, $segment);
- $dataTable->filter('GroupBy', array('label', function ($browserWithVersion) {
- if (preg_match("/(.+) [0-9]+(?:\.[0-9]+)?$/", $browserWithVersion, $matches) === 0) {
- return $browserWithVersion;
- }
- return $matches[1];
- }));
- }
- }
-
- /**
* Gets datatable displaying number of visits by Browser version (eg. Firefox 20, Safari 6.0)
* @param int $idSite
* @param string $period