Skip to content

Commit

Permalink
fixes #3892 Fixing + testing filter_truncate on getPlugin
Browse files Browse the repository at this point in the history
  • Loading branch information
mattab committed Apr 14, 2013
1 parent 1c41d3c commit 7853d2d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions core/DataTable/Row.php
Expand Up @@ -492,6 +492,9 @@ public function sumRow(Piwik_DataTable_Row $rowToSum, $enableCopyMetadata = true
private function getColumnValuesMerged($operation, $thisColumnValue, $columnToSumValue)
{
switch ($operation) {
case 'skip':
$newValue = null;
break;
case 'max':
$newValue = max($thisColumnValue, $columnToSumValue);
break;
Expand Down
5 changes: 5 additions & 0 deletions plugins/UserSettings/API.php
Expand Up @@ -215,6 +215,11 @@ public function getPlugin($idSite, $period, $date, $segment = false)

$visitsSum = $visitsSumTotal - $ieVisits;


// When Truncate filter is applied, it will call AddSummaryRow which tries to sum all rows.
// We tell the object to skip the column nb_visits_percentage when aggregating (since it's not correct to sum % values)
$table->setColumnAggregationOperation('nb_visits_percentage', 'skip');

// The filter must be applied now so that the new column can
// be sorted by the generic filters (applied right after this loop exits)
$table->filter('ColumnCallbackAddColumnPercentage', array('nb_visits_percentage', Piwik_Archive::INDEX_NB_VISITS, $visitsSum, 1));
Expand Down
3 changes: 3 additions & 0 deletions plugins/UserSettings/functions.php
Expand Up @@ -16,6 +16,9 @@

function Piwik_getPluginsLogo($oldLabel)
{
if($oldLabel == Piwik_Translate('General_Others')) {
return false;
}
return 'plugins/UserSettings/images/plugins/' . $oldLabel . '.gif';
}

Expand Down
Expand Up @@ -24,7 +24,12 @@ public function testApi($api, $params)

public function getApiForTesting()
{
$apiToCall = array('Referers.getKeywords', 'Actions.getPageUrls');
$apiToCall = array(
'Referers.getKeywords',
'Actions.getPageUrls',

// Specifically testing getPlugin filter_truncate works
'UserSettings.getPlugin');

return array(
array($apiToCall, array('idSite' => self::$fixture->idSite,
Expand Down

0 comments on commit 7853d2d

Please sign in to comment.