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:
authorThomas Steur <thomas.steur@googlemail.com>2014-08-15 12:34:44 +0400
committerThomas Steur <thomas.steur@googlemail.com>2014-08-15 12:34:44 +0400
commit1a40bc2c589e6f74621d1126454bd5901aa302ff (patch)
tree390261f5dea8bc6a66ceb812f222be44192d02e7 /plugins
parent1d212579eaa0de07f0c78f9e43d4aab32249d754 (diff)
fixes #5964 I was now able to reproduce after I understood the problem. Thx for such a good issue description, should have read more carefully in the beginning. Segments are now applied to the total value resulting in different movers and shakers depending on the segment
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Insights/API.php8
-rw-r--r--plugins/Insights/Model.php4
-rw-r--r--plugins/Insights/tests/ModelTest.php12
3 files changed, 15 insertions, 9 deletions
diff --git a/plugins/Insights/API.php b/plugins/Insights/API.php
index 0a2a66970d..20cb649649 100644
--- a/plugins/Insights/API.php
+++ b/plugins/Insights/API.php
@@ -215,12 +215,12 @@ class API extends \Piwik\Plugin\API
throw new \Exception('A report having the ID ' . $reportUniqueId . ' does not exist');
}
- $totalValue = $this->model->getTotalValue($idSite, $period, $date, $metric);
+ $totalValue = $this->model->getTotalValue($idSite, $period, $date, $metric, $segment);
$currentReport = $this->model->requestReport($idSite, $period, $date, $reportUniqueId, $metric, $segment);
$this->checkReportIsValid($currentReport);
$lastDate = $this->model->getLastDate($date, $period, $comparedToXPeriods);
- $lastTotalValue = $this->model->getTotalValue($idSite, $period, $lastDate, $metric);
+ $lastTotalValue = $this->model->getTotalValue($idSite, $period, $lastDate, $metric, $segment);
$lastReport = $this->model->requestReport($idSite, $period, $lastDate, $reportUniqueId, $metric, $segment);
$this->checkReportIsValid($lastReport);
@@ -269,12 +269,12 @@ class API extends \Piwik\Plugin\API
throw new \Exception('A report having the ID ' . $reportUniqueId . ' does not exist');
}
- $totalValue = $this->model->getTotalValue($idSite, $period, $date, $metric);
+ $totalValue = $this->model->getTotalValue($idSite, $period, $date, $metric, $segment);
$currentReport = $this->model->requestReport($idSite, $period, $date, $reportUniqueId, $metric, $segment);
$this->checkReportIsValid($currentReport);
$lastDate = $this->model->getLastDate($date, $period, $comparedToXPeriods);
- $lastTotalValue = $this->model->getTotalValue($idSite, $period, $lastDate, $metric);
+ $lastTotalValue = $this->model->getTotalValue($idSite, $period, $lastDate, $metric, $segment);
$lastReport = $this->model->requestReport($idSite, $period, $lastDate, $reportUniqueId, $metric, $segment);
$this->checkReportIsValid($lastReport);
diff --git a/plugins/Insights/Model.php b/plugins/Insights/Model.php
index 3f9ac956b4..9dae23c978 100644
--- a/plugins/Insights/Model.php
+++ b/plugins/Insights/Model.php
@@ -83,9 +83,9 @@ class Model
return $totalValue;
}
- public function getTotalValue($idSite, $period, $date, $metric)
+ public function getTotalValue($idSite, $period, $date, $metric, $segment)
{
- $visits = VisitsSummaryAPI::getInstance()->get($idSite, $period, $date, false, array($metric));
+ $visits = VisitsSummaryAPI::getInstance()->get($idSite, $period, $date, $segment, array($metric));
$firstRow = $visits->getFirstRow();
if (empty($firstRow)) {
diff --git a/plugins/Insights/tests/ModelTest.php b/plugins/Insights/tests/ModelTest.php
index 12bd283949..fdabe70561 100644
--- a/plugins/Insights/tests/ModelTest.php
+++ b/plugins/Insights/tests/ModelTest.php
@@ -131,19 +131,25 @@ class ModelTest extends IntegrationTestCase
public function test_getTotalValue_shouldCalculateTotals()
{
- $total = $this->model->getTotalValue(self::$fixture->idSite, 'day', self::$fixture->date1, 'nb_visits');
+ $total = $this->model->getTotalValue(self::$fixture->idSite, 'day', self::$fixture->date1, 'nb_visits', false);
$this->assertEquals(50, $total);
- $total = $this->model->getTotalValue(self::$fixture->idSite, 'day', self::$fixture->date2, 'nb_visits');
+ $total = $this->model->getTotalValue(self::$fixture->idSite, 'day', self::$fixture->date2, 'nb_visits', false);
$this->assertEquals(59, $total);
}
+ public function test_getTotalValue_shouldCalculateTotalsAndApplySegment()
+ {
+ $total = $this->model->getTotalValue(self::$fixture->idSite, 'day', self::$fixture->date1, 'nb_visits', 'visitIp==156.15.13.1');
+ $this->assertEquals(1, $total);
+ }
+
/**
* @expectedException \Exception
*/
public function test_getTotalValue_shouldReturnZero_IfColumnDoesNotExist()
{
- $this->model->getTotalValue(self::$fixture->idSite, 'day', self::$fixture->date1, 'unknown_ColUmn');
+ $this->model->getTotalValue(self::$fixture->idSite, 'day', self::$fixture->date1, 'unknown_ColUmn', false);
}
public function test_getRelevantTotalValue_shouldReturnTotalValue_IfMetricTotalIsHighEnough()