Skip to content

Commit

Permalink
Fixes matomo-org#6756, fix two regressions/bugs in row evolution of e…
Browse files Browse the repository at this point in the history
…commerce item report: viewDataTable is overwritten by BaseEcommerceItem Report class metadata causing UI bugs since viewDataTable is not graphEvolution, graph visualizations should not format metrics in any way prior to generating jqplot JSON.
  • Loading branch information
diosmosis committed Dec 2, 2014
1 parent 2b21d9b commit 61f0e6a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
12 changes: 7 additions & 5 deletions core/Plugin/Visualization.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,13 @@ private function applyFilters()
$this->dataTable->applyQueuedFilters();
}

$formatter = $this->metricsFormatter;
$report = $this->report;
$this->dataTable->filter(function (DataTable $table) use ($formatter, $report) {
$formatter->formatMetrics($table, $report);
});
if ($this->requestConfig->shouldFormatMetrics()) {
$formatter = $this->metricsFormatter;
$report = $this->report;
$this->dataTable->filter(function (DataTable $table) use ($formatter, $report) {
$formatter->formatMetrics($table, $report);
});
}
}

private function removeEmptyColumnsFromDisplay()
Expand Down
5 changes: 5 additions & 0 deletions core/ViewDataTable/RequestConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -356,4 +356,9 @@ public function getApiMethodToRequest()

return $method;
}

public function shouldFormatMetrics()
{
return Common::getRequestVar('format_metrics', '1', 'string', $this->request_parameters_to_modify) != 0;
}
}
1 change: 0 additions & 1 deletion plugins/CoreVisualizations/JqplotDataGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ public function generate($dataTable)
$dataTable->queueFilter('AddSummaryRow', Piwik::translate('General_Total'));
}

$dataTable->applyQueuedFilters();
$this->initChartObjectData($dataTable, $visualization);
}

Expand Down
2 changes: 2 additions & 0 deletions plugins/CoreVisualizations/Visualizations/Graph.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ public function beforeLoadDataTable()
$this->requestConfig->request_parameters_to_modify['filter_truncate'] = $this->config->max_graph_elements - 1;
}

$this->requestConfig->disable_queued_filters = 1;
$this->requestConfig->request_parameters_to_modify['disable_queued_filters'] = 1;
$this->requestConfig->request_parameters_to_modify['format_metrics'] = 0;
}

/**
Expand Down
8 changes: 6 additions & 2 deletions plugins/Goals/Reports/BaseEcommerceItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
use Piwik\Piwik;
use Piwik\Plugin\Report;
use Piwik\Plugin\ViewDataTable;
use Piwik\Plugins\CoreVisualizations\Visualizations\JqplotGraph\Evolution;
use Piwik\Plugins\CustomPages\Visualization\HtmlTable;
use Piwik\Plugins\Goals\Goals;
use Piwik\Plugins\Goals\Columns\Metrics\AveragePrice;
use Piwik\Plugins\Goals\Columns\Metrics\AverageQuantity;
Expand Down Expand Up @@ -105,8 +107,10 @@ public function configureView(ViewDataTable $view)
$view->config->addTranslations($translations);
$view->config->columns_to_display = $columnsOrdered;

$view->config->custom_parameters['viewDataTable'] =
$abandonedCart ? Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_CART : Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER;
if ($view instanceof HtmlTable) {
$view->config->custom_parameters['viewDataTable'] =
$abandonedCart ? Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_CART : Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER;
}
}

private function isAbandonedCart()
Expand Down

0 comments on commit 61f0e6a

Please sign in to comment.