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-03-10 03:53:31 +0400
committerThomas Steur <thomas.steur@googlemail.com>2014-03-10 03:53:31 +0400
commitd210180a4609f8f89107e10fe8a4eafe577eaa24 (patch)
tree4eff7eccbbb5a9e16ac23917292b6e6896b3e84c /plugins/Insights/InsightReport.php
parentf87c208baba8b552872b8a9659269d7fc9109804 (diff)
refs #57 ui tweaks and translations
Diffstat (limited to 'plugins/Insights/InsightReport.php')
-rw-r--r--plugins/Insights/InsightReport.php25
1 files changed, 19 insertions, 6 deletions
diff --git a/plugins/Insights/InsightReport.php b/plugins/Insights/InsightReport.php
index 7c62df9344..88644f265a 100644
--- a/plugins/Insights/InsightReport.php
+++ b/plugins/Insights/InsightReport.php
@@ -37,13 +37,12 @@ class InsightReport
*/
public function generateMoverAndShaker($reportMetadata, $period, $date, $lastDate, $metric, $currentReport, $lastReport, $totalValue, $lastTotalValue, $orderBy, $limitIncreaser, $limitDecreaser)
{
- $totalEvolution = Piwik::getPercentageSafe($totalValue - $lastTotalValue, $lastTotalValue, 1);
+ $totalEvolution = $this->getTotalEvolution($totalValue, $lastTotalValue);
$minMoversPercent = 1;
if ($totalEvolution >= 100) {
// eg change from 50 to 150 = 200%
- // $evolutionReverse = Piwik::getPercentageSafe($totalValue > $lastTotal ? $lastTotal : $totalValue, $totalValue > $lastTotal ? $totalValue : $lastTotal, 1);
$factor = (int) ceil($totalEvolution / 500);
$minGrowthPercentPositive = $totalEvolution + ($factor * 40); // min +240%
$minGrowthPercentNegative = -70; // min -70%
@@ -64,7 +63,7 @@ class InsightReport
$minNewPercent = 5;
}
- if ($totalValue < 200 && $totalValue > 0) {
+ if ($totalValue < 200 && $totalValue != 0) {
// force at least a change of 2 visits
$minMoversPercent = (int) ceil(2 / ($totalValue / 100));
$minNewPercent = max($minNewPercent, $minMoversPercent);
@@ -73,9 +72,7 @@ class InsightReport
$dataTable = $this->generateInsight($reportMetadata, $period, $date, $lastDate, $metric, $currentReport, $lastReport, $totalValue, $minMoversPercent, $minNewPercent, $minDisappearedPercent, $minGrowthPercentPositive, $minGrowthPercentNegative, $orderBy, $limitIncreaser, $limitDecreaser);
- $dataTable->setMetadata('lastTotalValue', $lastTotalValue);
- $dataTable->setMetadata('evolutionTotal', $totalEvolution);
- $dataTable->setMetadata('evolutionDifference', $totalValue - $lastTotalValue);
+ $this->addMoversAndShakersMetadata($dataTable, $totalValue, $lastTotalValue);
return $dataTable;
}
@@ -113,6 +110,8 @@ class InsightReport
$row->setColumn('isMoverAndShaker', false);
}
}
+
+ $this->addMoversAndShakersMetadata($insight, $totalValue, $lastTotalValue);
}
/**
@@ -266,4 +265,18 @@ class InsightReport
return (int) $minVisits;
}
+
+ private function addMoversAndShakersMetadata(DataTable $dataTable, $totalValue, $lastTotalValue)
+ {
+ $totalEvolution = $this->getTotalEvolution($totalValue, $lastTotalValue);
+
+ $dataTable->setMetadata('lastTotalValue', $lastTotalValue);
+ $dataTable->setMetadata('evolutionTotal', $totalEvolution);
+ $dataTable->setMetadata('evolutionDifference', $totalValue - $lastTotalValue);
+ }
+
+ private function getTotalEvolution($totalValue, $lastTotalValue)
+ {
+ return Piwik::getPercentageSafe($totalValue - $lastTotalValue, $lastTotalValue, 1);
+ }
}