Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge remote-tracking branch 'origin/master'

  • Loading branch information...
commit e1ed6cf2c7ce7b2d125be7619ef16816422885b6 2 parents 45d316e + d9c02e6
@mattab mattab authored
View
31 lang/en.json
@@ -1038,6 +1038,37 @@
"VisitsUntilConv": "Visits to Conversion",
"DaysToConv": "Days to Conversion"
},
+ "Insights": {
+ "OverviewWidgetTitle": "Insights Overview",
+ "WidgetCategory": "Insights",
+ "NoResultMatchesCriteria": "No rows match the criteria",
+ "MoversAndShakersWidgetTitle": "Movers and Shakers",
+ "TitleRowChangeDetails": "'%s' changed from %s (%s) to %s (%s) %s.",
+ "TitleRowNewDetails": "'%s' increased by %s and is new compared to %s.",
+ "TitleRowDisappearedDetails": "'%s' decreased by %s and disappeared in %s compared to %s.",
+ "TitleRowMoverAndShaker": "This row had an higher impact than the average.",
+ "IgnoredChanges": "Changes affecting less than %s visits were ignored.",
+ "TitleConsideredInsightsGrowth": "The following rows have a growth of at least %s%% compared to %s.",
+ "TitleConsideredInsightsChanges": "The rows increased or decreased by at least %s visits (%s%% of %s total visits).",
+ "TitleConsideredMoversAndShakersGrowth": "%s changed from %s to %s compared to %s. Based on this an evolution of each row of %s%% is expected.",
+ "TitleConsideredMoversAndShakersChanges": "Considered movers only if they grew by more than %s%% visits or shrank by less than %s%% visits, new entries only if they increased by more than %s%% visits (%s), and disappeared rows if they shrank by less than %s%% visits (%s).",
+ "DatePeriodCombinationNotSupported": "It is not possible to generate insights for this date / period combination.",
+ "ControlGrowthDescription": "Minimum growth of",
+ "ControlComparedToDescription": "compared to the",
+ "DayComparedToPreviousDay": "previous day",
+ "DayComparedToPreviousWeek": "same day in the previous week",
+ "DayComparedToPreviousYear": "same day in the previous year",
+ "WeekComparedToPreviousWeek": "previous week",
+ "MonthComparedToPreviousMonth": "previous month",
+ "MonthComparedToPreviousYear": "same month in the previous year",
+ "Filter": "Filter",
+ "FilterOnlyMovers": "Only movers",
+ "FilterOnlyNew": "Only new",
+ "FilterOnlyDisappeared": "Only disappeared",
+ "FilterIncreaserAndDecreaser": "Increaser & decreaser",
+ "FilterOnlyIncreaser": "Only increaser",
+ "FilterOnlyDecreaser": "Only decreaser"
+ },
"Installation": {
"PluginDescription": "Installation process of Piwik. The Installation is usually done once only. If the configuration file config\/config.inc.php is deleted, the installation will start again.",
"Installation": "Installation",
View
43 plugins/CoreConsole/Commands/ActivatePlugin.php
@@ -0,0 +1,43 @@
+<?php
+/**
+ * Piwik - Open source web analytics
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+
+namespace Piwik\Plugins\CoreConsole\Commands;
+
+use Piwik\Plugin\Manager;
+use Piwik\Plugin\ConsoleCommand;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
+
+/**
+ * @package CloudAdmin
+ */
+class ActivatePlugin extends ConsoleCommand
+{
+ protected function configure()
+ {
+ $this->setName('plugin:activate');
+ $this->setDescription("Activate a plugin.");
+ $this->addArgument("plugins", InputArgument::REQUIRED | InputArgument::IS_ARRAY, 'Plugin name(s) to activate.');
+ $this->addOption('domain', null, InputOption::VALUE_REQUIRED, "The domain to activate the plugin for.");
+ }
+
+ /**
+ * Execute command like: ./console cloudadmin:plugin activate CustomAlerts --piwik-domain=testcustomer.piwik.pro
+ */
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $plugins = $input->getArgument('plugins');
+ foreach ($plugins as $plugin) {
+ Manager::getInstance()->activatePlugin($plugin);
+
+ $output->writeln("Activating plugin <info>$plugin</info>");
+ }
+ }
+}
View
43 plugins/CoreConsole/Commands/DeactivatePlugin.php
@@ -0,0 +1,43 @@
+<?php
+/**
+ * Piwik - Open source web analytics
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+
+namespace Piwik\Plugins\CoreConsole\Commands;
+
+use Piwik\Plugin\Manager;
+use Piwik\Plugin\ConsoleCommand;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
+
+/**
+ * @package CloudAdmin
+ */
+class DeactivatePlugin extends ConsoleCommand
+{
+ protected function configure()
+ {
+ $this->setName('plugin:deactivate');
+ $this->setDescription("Deactivate a plugin.");
+ $this->addArgument("plugins", InputArgument::REQUIRED | InputArgument::IS_ARRAY, 'Plugin name(s) to deactivate.');
+ $this->addOption('domain', null, InputOption::VALUE_REQUIRED, "The domain to deactivate the plugin for.");
+ }
+
+ /**
+ * Execute command like: ./console cloudadmin:plugin activate CustomAlerts --piwik-domain=testcustomer.piwik.pro
+ */
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $plugins = $input->getArgument('plugins');
+ foreach ($plugins as $plugin) {
+ Manager::getInstance()->deactivatePlugin($plugin);
+
+ $output->writeln("Activating plugin <info>$plugin</info>");
+ }
+ }
+}
View
2  plugins/CoreConsole/CoreConsole.php
@@ -39,5 +39,7 @@ public function addConsoleCommands(&$commands)
$commands[] = 'Piwik\Plugins\CoreConsole\Commands\GenerateTest';
$commands[] = 'Piwik\Plugins\CoreConsole\Commands\GenerateCommand';
$commands[] = 'Piwik\Plugins\CoreConsole\Commands\SyncUITestScreenshots';
+ $commands[] = 'Piwik\Plugins\CoreConsole\Commands\ActivatePlugin';
+ $commands[] = 'Piwik\Plugins\CoreConsole\Commands\DeactivatePlugin';
}
}
View
38 plugins/Insights/DataTable/Filter/Average.php
@@ -1,38 +0,0 @@
-<?php
-/**
- * Piwik - Open source web analytics
- *
- * @link http://piwik.org
- * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
- *
- */
-namespace Piwik\Plugins\Insights\DataTable\Filter;
-
-use Piwik\DataTable;
-
-class Average extends DataTable\BaseFilter
-{
- private $divisor;
-
- public function __construct($table, $columnToRead, $divisor)
- {
- $this->columnToRead = $columnToRead;
- $this->divisor = $divisor;
- }
-
- public function filter($table)
- {
- if (!$this->divisor) {
- return;
- }
-
- foreach ($table->getRows() as $row) {
-
- $value = $row->getColumn($this->columnToRead);
-
- if (false !== $value && is_numeric($value)) {
- $row->setColumn($this->columnToRead, round($value / $this->divisor));
- }
- }
- }
-}
View
25 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 @@ public function generateMoverAndShaker($reportMetadata, $period, $date, $lastDat
$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 @@ public function generateMoverAndShaker($reportMetadata, $period, $date, $lastDat
$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 @@ public function markMoversAndShakers(DataTable $insight, $currentReport, $lastRe
$row->setColumn('isMoverAndShaker', false);
}
}
+
+ $this->addMoversAndShakersMetadata($insight, $totalValue, $lastTotalValue);
}
/**
@@ -266,4 +265,18 @@ private function getMinVisits($totalValue, $percent)
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);
+ }
}
View
15 plugins/Insights/lang/en.json
@@ -1,15 +0,0 @@
-{
- "Insights": {
- "OverviewWidgetTitle": "Insights Overview",
- "WidgetCategory": "Insights",
- "NoResultMatchesCriteria": "No rows match the criteria",
- "MoversAndShakersWidgetTitle": "Movers and Shakers",
- "TitleConsideredVisits": "Considered rows having a growth of at least %s%% compared to %s.",
- "TitleConsideredChanges": "Considered movers only if they increased or decreased by more than %s visits, new entries only if they increase by more than %s visits, and disappeared rows if they decreased by more than %s visits based on %s total visits.",
- "TitleReportBasedOn": "Based on %s %s, rows less than %s %s were ignored",
- "TitleRowChangeDetails": "'%s' changed from %s (%s) to %s (%s) %s",
- "TitleIgnoredChanges": "Changes affecting less than %s visits were ignored.",
- "TitleConsideredMoversAndShakers": "Visits changed from %s to %s compared to %s. Based on this an evolution of each row of %s%% is expected.",
- "TitleConsideredChangesMoversAndShakers": "Considered movers only if they grew by more than %s%% visits or less than %s%% visits, new entries only if they increased by more than %s%% visits (%s), and disappeared rows if they descreased by less than %s%% visits (%s)"
- }
-}
View
7 plugins/Insights/stylesheets/insightVisualization.less
@@ -5,6 +5,13 @@
}
.insightsDataTable {
+
+ .controlSeparator {
+ height: 1px;
+ border: 0px;
+ background-color: #cccccc;
+ }
+
th.orderBy {
width: 20%;
}
View
2  plugins/Insights/templates/cannotDisplayReport.twig
@@ -1,3 +1,3 @@
<div class="pk-emptyDataTable">
- It is not possible to generate insights for this date / period combination.
+ {{ 'Insights_DatePeriodCombinationNotSupported'|translate }}
</div>
View
45 plugins/Insights/templates/insightControls.twig
@@ -1,6 +1,7 @@
<div style="padding: 10px;padding-bottom: 0px;">
- Minimum growth of
+ {{ 'Insights_ControlGrowthDescription'|translate }}
+
<select size="1" name="minGrowthPercent">
{% for i in range(0, 1, 1) %}
<option {% if i == properties.min_growth_percent %}selected{% endif %} value="{{ i }}">{{ i }}%</option>
@@ -14,53 +15,63 @@
</select>
{% if period == 'day' or period == 'month' or period == 'week' %}
- compared to
+
+ {{ 'Insights_ControlComparedToDescription'|translate }}
+
{% if period == 'day' %}
<select size="1" name="comparedToXPeriodsAgo">
<option value="1" {% if properties.compared_to_x_periods_ago == 1 %}selected{% endif %}>
- previous day
+ {{ 'Insights_DayComparedToPreviousDay'|translate }}
</option>
<option value="7" {% if properties.compared_to_x_periods_ago == 7 %}selected{% endif %}>
- same day in previous week
+ {{ 'Insights_DayComparedToPreviousWeek'|translate }}
</option>
<option value="365" {% if properties.compared_to_x_periods_ago == 365 %}selected{% endif %}>
- same day in previous year
+ {{ 'Insights_DayComparedToPreviousYear'|translate }}
</option>
</select>
{% elseif period == 'month' %}
<select size="1" name="comparedToXPeriodsAgo">
<option value="1" {% if properties.compared_to_x_periods_ago == 1 %}selected{% endif %}>
- previous month
+ {{ 'Insights_MonthComparedToPreviousMonth'|translate }}
</option>
<option value="12" {% if properties.compared_to_x_periods_ago == 12 %}selected{% endif %}>
- same month in previous year
+ {{ 'Insights_MonthComparedToPreviousYear'|translate }}
</option>
</select>
{% elseif period == 'week' %}
- previous week
+ {{ 'Insights_WeekComparedToPreviousWeek'|translate }}
{% endif %}
{% endif %}
- <hr style="height: 1px;border: 0px;background-color: #cccccc;" />
+ <hr class="controlSeparator" />
- Filter
+ {{ 'Insights_Filter'|translate }}
<select size="1" name="filterBy" title="Show all, only movers, only new, only disappeared">
- <option {% if not properties.filter_by %}selected{% endif %} value="">All</option>
- <option {% if properties.filter_by == 'movers' %}selected{% endif %} value="movers">Only movers</option>
- <option {% if properties.filter_by == 'new' %}selected{% endif %} value="new">Only new</option>
- <option {% if properties.filter_by == 'disappeared' %}selected{% endif %} value="disappeared">Only disappeared</option>
+ <option {% if not properties.filter_by %}selected{% endif %} value="">
+ {{ 'General_All'|translate }}
+ </option>
+ <option {% if properties.filter_by == 'movers' %}selected{% endif %} value="movers">
+ {{ 'Insights_FilterOnlyMovers'|translate }}
+ </option>
+ <option {% if properties.filter_by == 'new' %}selected{% endif %} value="new">
+ {{ 'Insights_FilterOnlyNew'|translate }}
+ </option>
+ <option {% if properties.filter_by == 'disappeared' %}selected{% endif %} value="disappeared">
+ {{ 'Insights_FilterOnlyDisappeared'|translate }}
+ </option>
</select>
<select size="1" name="showIncreaseOrDecrease" title="Show increaser and/or decreaser">
<option value="both" {% if properties.limit_increaser and properties.limit_decreaser %}selected{%endif%}>
- Increaser & decreaser
+ {{ 'Insights_FilterIncreaserAndDecreaser'|translate }}
</option>
<option value="increase" {% if properties.limit_increaser and not properties.limit_decreaser %}selected{%endif%}>
- Only increaser
+ {{ 'Insights_FilterOnlyIncreaser'|translate }}
</option>
<option value="decrease" {% if not properties.limit_increaser and properties.limit_decreaser %}selected{%endif%}>
- Only decreaser
+ {{ 'Insights_FilterOnlyDecreaser'|translate }}
</option>
</select>
</div>
View
6 plugins/Insights/templates/insightVisualization.twig
@@ -2,14 +2,14 @@
{% include "@Insights/cannotDisplayReport.twig" %}
{% else %}
{% set metadata = dataTable.getAllTableMetadata%}
- {% set consideredVisits = 'Insights_TitleConsideredVisits'|translate(metadata.minGrowthPercentPositive, metadata.lastDate|prettyDate(metadata.period)) %}
+ {% set consideredGrowth = 'Insights_TitleConsideredInsightsGrowth'|translate(metadata.minGrowthPercentPositive, metadata.lastDate|prettyDate(metadata.period)) %}
{% set consideredChanges = '' %}
{% if metadata.minChangeMovers and metadata.minChangeMovers > 1 %}
- {% set consideredChanges = 'Insights_TitleIgnoredChanges'|translate(metadata.minChangeMovers) %}
+ {% set consideredChanges = 'Insights_IgnoredChanges'|translate(metadata.minChangeMovers) %}
{% endif %}
- <div class="insightsDataTable" title="{{ consideredVisits|e('html_attr') }} {{ consideredChanges|e('html_attr') }}">
+ <div class="insightsDataTable" title="{{ consideredGrowth|e('html_attr') }} {{ consideredChanges|e('html_attr') }}">
{% if dataTable.getRowsCount %}
<table class="dataTable">
View
7 plugins/Insights/templates/insightsOverviewWidget.twig
@@ -1,10 +1,5 @@
{% set allMetadata = reports.getFirstRow.getAllTableMetadata %}
-
-{% set consideredVisits = 'Insights_TitleConsideredVisits'|translate(allMetadata.minGrowthPercentPositive, allMetadata.lastDate|prettyDate(allMetadata.period)) %}
+{% set consideredGrowth = 'Insights_TitleConsideredInsightsGrowth'|translate(allMetadata.minGrowthPercentPositive, allMetadata.lastDate|prettyDate(allMetadata.period)) %}
{% set consideredChanges = '' %}
-{% if allMetadata.minChangeMovers or allMetadata.minIncreaseNew or allMetadata.minDecreaseDisappeared %}
- {% set consideredChanges = 'Insights_TitleConsideredChanges'|translate(allMetadata.minChangeMovers, allMetadata.minIncreaseNew, allMetadata.minDecreaseDisappeared, allMetadata.totalValue) %}
-{% endif %}
-
{% include "@Insights/overviewWidget.twig" %}
View
8 plugins/Insights/templates/moversAndShakersOverviewWidget.twig
@@ -1,10 +1,6 @@
{% set allMetadata = reports.getFirstRow.getAllTableMetadata %}
-{% set consideredVisits = 'Insights_TitleConsideredMoversAndShakers'|translate(allMetadata.lastTotalValue, allMetadata.totalValue, allMetadata.lastDate|prettyDate(allMetadata.period), allMetadata.evolutionTotal) %}
-{% set consideredChanges = '' %}
-
-{% if allMetadata.minChangeMovers or allMetadata.minIncreaseNew or allMetadata.minDecreaseDisappeared %}
- {% set consideredChanges = 'Insights_TitleConsideredChangesMoversAndShakers'|translate(allMetadata.minGrowthPercentPositive, allMetadata.minGrowthPercentNegative, allMetadata.minNewPercent, allMetadata.minIncreaseNew, allMetadata.minDisappearedPercent, allMetadata.minDecreaseDisappeared, allMetadata.totalValue) %}
-{% endif %}
+{% set consideredGrowth = 'Insights_TitleConsideredMoversAndShakersGrowth'|translate(allMetadata.metricName, allMetadata.lastTotalValue, allMetadata.totalValue, allMetadata.lastDate|prettyDate(allMetadata.period), allMetadata.evolutionTotal) %}
+{% set consideredChanges = 'Insights_TitleConsideredMoversAndShakersChanges'|translate(allMetadata.minGrowthPercentPositive, allMetadata.minGrowthPercentNegative, allMetadata.minNewPercent, allMetadata.minIncreaseNew, allMetadata.minDisappearedPercent, allMetadata.minDecreaseDisappeared, allMetadata.totalValue) %}
{% include "@Insights/overviewWidget.twig" %}
View
20 plugins/Insights/templates/overviewWidget.twig
@@ -1,14 +1,15 @@
<div class="insightsDataTable dataTable"
data-table-type="InsightsDataTable"
- data-table-onlyinsightsinit="1"
- title="{{ consideredVisits|e('html_attr') }} {{ consideredChanges|e('html_attr') }}">
+ data-table-onlyinsightsinit="1">
{% if reports.getColumns|length > 0 %}
- <table class="dataTable">
- {% for dataTable in reports.getDataTables() if dataTable.getRowsCount > 0 %}
- {% set metadata = dataTable.getAllTableMetadata %}
+ {% for dataTable in reports.getDataTables() if dataTable.getRowsCount > 0 %}
+ {% set metadata = dataTable.getAllTableMetadata %}
- <thead>
+ <table class="dataTable"
+ title="{{ consideredGrowth|e('html_attr') }} {{ consideredChanges|e('html_attr') }}">
+
+ <thead >
{% include "@Insights/table_header.twig" %}
</thead>
@@ -18,8 +19,8 @@
{% endfor %}
</tbody>
- {% endfor %}
- </table>
+ </table>
+ {% endfor %}
<script type="text/javascript" defer="defer">
$(document).ready(function () {
@@ -29,7 +30,8 @@
{% else %}
- <div class="pk-emptyDataTable">
+ <div class="pk-emptyDataTable"
+ title="{{ consideredGrowth|e('html_attr') }} {{ consideredChanges|e('html_attr') }}">
{{ 'Insights_NoResultMatchesCriteria'|translate }}
</div>
View
25 plugins/Insights/templates/table_row.twig
@@ -1,19 +1,24 @@
-<tr title="{{ 'Insights_TitleRowChangeDetails'|translate(row.getColumn('label'), row.getColumn('value_old'), metadata.lastDate|prettyDate(metadata.period), row.getColumn('value_new'), metadata.date|prettyDate(metadata.period), metadata.metricName)|e('html_attr') }}"
- {% if row.getColumn('isMoverAndShaker') %}class="isMoverAndShaker"{% endif %}>
+{% if row.getColumn('isDisappeared') %}
+ {% set rowTitle = 'Insights_TitleRowDisappearedDetails'|translate(row.getColumn('label'), row.getColumn('value_old'), metadata.date|prettyDate(metadata.period), metadata.lastDate|prettyDate(metadata.period)) %}
+{% elseif row.getColumn('isNew') %}
+ {% set rowTitle = 'Insights_TitleRowNewDetails'|translate(row.getColumn('label'), row.getColumn('value_new'), metadata.lastDate|prettyDate(metadata.period)) %}
+{% else %}
+ {% set rowTitle = 'Insights_TitleRowChangeDetails'|translate(row.getColumn('label'), row.getColumn('value_old'), metadata.lastDate|prettyDate(metadata.period), row.getColumn('value_new'), metadata.date|prettyDate(metadata.period), metadata.metricName) %}
+{% endif %}
+
+{% set rowTitleShaker = '' %}
+{% if row.getColumn('isMoverAndShaker') %}
+ {% set rowTitleShaker = 'Insights_TitleRowMoverAndShaker'|translate %}
+{% endif %}
+
+<tr title="{{ rowTitle|e('html_attr') }} {{ rowTitleShaker|e('html_attr') }}"
+ class="{% if row.getColumn('isMoverAndShaker') %}isMoverAndShaker{% endif %}">
<td class="label">
<span class="title">
{{ row.getColumn('label') }}
</span>
</td>
- {% if row.getColumn('isMover') %}
- {% set typeOfChange = 'Moved' %}
- {% elseif row.getColumn('isNew') %}
- {% set typeOfChange = 'New' %}
- {% elseif row.getColumn('isDisappeared') %}
- {% set typeOfChange = 'Disappeared' %}
- {% endif %}
-
{% if row.getColumn('grown') %}
<td>+{{ row.getColumn('difference') }}</td>
<td class="grown">+{{ row.getColumn('growth_percent') }}</td>
View
77 plugins/Insights/tests/FilterAverageTest.php
@@ -1,77 +0,0 @@
-<?php
-/**
- * Piwik - Open source web analytics
- *
- * @link http://piwik.org
- * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
- */
-
-namespace Piwik\Plugins\Insights\tests;
-
-use Piwik\DataTable;
-use Piwik\DataTable\Row;
-use Piwik\Plugins\Insights\DataTable\Filter\Average;
-
-/**
- * @group Insights
- * @group FilterAverageTest
- * @group Unit
- * @group Core
- */
-class FilterAverageTest extends BaseUnitTest
-{
- public function setUp()
- {
- $this->table = new DataTable();
- $this->table->addRowsFromArray(array(
- array(Row::COLUMNS => array('label' => 'val1', 'growth' => 22)),
- array(Row::COLUMNS => array('label' => 'val2', 'growth' => 14)),
- array(Row::COLUMNS => array('label' => 'val3', 'growth' => 18)),
- array(Row::COLUMNS => array('label' => 'val4', 'growth' => 20)),
- array(Row::COLUMNS => array('label' => 'val5', 'growth' => 25)),
- array(Row::COLUMNS => array('label' => 'val6', 'growth' => 17)),
- array(Row::COLUMNS => array('label' => 'val7', 'growth' => 0)),
- array(Row::COLUMNS => array('label' => 'val8', 'growth' => 4)),
- array(Row::COLUMNS => array('label' => 'val9', 'growth' => -4)),
- array(Row::COLUMNS => array('label' => 'val10', 'growth' => null)),
- array(Row::COLUMNS => array('label' => 'val11', 'growth' => false)),
- ));
- }
-
- public function testShouldNotChangeAnythingIfAverageIsZeroOrOne()
- {
- $rowsBefore = $this->table->getRows();
-
- $this->calculateAverage(0);
- $this->assertSame($rowsBefore, $this->table->getRows());
-
- $this->calculateAverage(1);
- $this->assertSame($rowsBefore, $this->table->getRows());
- }
-
- public function testShouldDivideNumericValuesByDivisorAndRound()
- {
- $this->calculateAverage(4);
-
- $this->assertColumnValues(array(
- array('label' => 'val1', 'growth' => 6),
- array('label' => 'val2', 'growth' => 4),
- array('label' => 'val3', 'growth' => 5),
- array('label' => 'val4', 'growth' => 5),
- array('label' => 'val5', 'growth' => 6),
- array('label' => 'val6', 'growth' => 4),
- array('label' => 'val7', 'growth' => 0),
- array('label' => 'val8', 'growth' => 1),
- array('label' => 'val9', 'growth' => -1),
- array('label' => 'val10', 'growth' => null),
- array('label' => 'val11', 'growth' => false),
- ));
- }
-
- private function calculateAverage($divisor)
- {
- $filter = new Average($this->table, 'growth', $divisor);
- $filter->filter($this->table);
- }
-
-}
View
24 plugins/Insights/tests/InsightReportTest.php
@@ -290,6 +290,19 @@ public function test_markMoversAndShakers()
$this->assertMoversAndShakers($report, $movers, $nonMovers);
}
+ public function test_markMoversAndShakers_shouldAddMetadata()
+ {
+ $report = $this->generateInsight(2, 2, 2, 5, -5);
+ $this->insightReport->markMoversAndShakers($report, $this->currentTable, $this->pastTable, 200, 100);
+
+ $metadata = $report->getAllTableMetadata();
+
+ $this->assertEquals(100, $metadata['lastTotalValue']);
+ $this->assertEquals(200, $metadata['totalValue']);
+ $this->assertEquals(100, $metadata['evolutionDifference']);
+ $this->assertEquals(100, $metadata['evolutionTotal']);
+ }
+
public function test_generateMoversAndShakers()
{
// increase by 60% --> minGrowth 80%
@@ -413,6 +426,17 @@ public function test_generateMoversAndShakers_ParameterCalculation()
$this->assertEquals(3, $metadata['minMoversPercent']);
$this->assertEquals(5, $metadata['minNewPercent']);
$this->assertEquals(7, $metadata['minDisappearedPercent']);
+
+
+ // make sure no division by zero issue
+ $report = $this->generateMoverAndShaker(0, 150);
+ $metadata = $report->getAllTableMetadata();
+
+ $this->assertEquals(120, $metadata['minGrowthPercentPositive']);
+ $this->assertEquals(-120, $metadata['minGrowthPercentNegative']);
+ $this->assertEquals(1, $metadata['minMoversPercent']);
+ $this->assertEquals(5, $metadata['minNewPercent']);
+ $this->assertEquals(7, $metadata['minDisappearedPercent']);
}
private function generateMoverAndShaker($totalValue, $lastTotalValue, $orderBy = null, $limitIncreaser = 99, $limitDecreaser = 99)
2  tests/PHPUnit/UI
@@ -1 +1 @@
-Subproject commit 0e1c7c2cff3195484d33b9f6c7ccd7ea0213723b
+Subproject commit 3472e286a38195739ae58721c55b77763b67bd29
View
1  tests/PHPUnit/travis.sh
@@ -26,6 +26,5 @@ else
fi
else
phpunit --configuration phpunit.xml --coverage-text --colors
- fi
fi
fi
Please sign in to comment.
Something went wrong with that request. Please try again.