@tsteur opened this Issue on November 26th 2012 Owner

Hi,

I found those "hideColumns/showColumns" parameters in API documentation. As I do always display only one value in Piwik Mobile App, this could be an interesting way to reduce the amount of transferred data a lot.

When using showColumns + Metadata.getProcessedReport I get a division by zero.

URL:
http://demo.piwik.org/index.php?idSite=25&date=today&hideMetricsDoc=1&filter_sort_column=nb_visits&hideColumns=nb_visits&apiModule=VisitTime&apiAction=getVisitInformationPerServerTime&period=year&filter_limit=30&module=API&format=json&method=API.getProcessedReport&language=en&

Answer:

Warning: Division by zero in /home/piwik/www/demo.piwik.org/core/DataTable/Filter/AddColumnsProcessedMetrics.php on line 59 

Backtrace -->

<a href='/0'>#0</a> Piwik_ErrorHandler(...) called at [/home/piwik/www/demo.piwik.org/core/DataTable/Filter/AddColumnsProcessedMetrics.php:59]
<a href='/1'>#1</a> Piwik_DataTable_Filter_AddColumnsProcessedMetrics->filter(...) called at [/home/piwik/www/demo.piwik.org/core/DataTable.php:388]
<a href='/2'>#2</a> Piwik_DataTable->filter(...) called at [/home/piwik/www/demo.piwik.org/plugins/API/API.php:807]
<a href='/3'>#3</a> Piwik_API_API->handleTableReport(...) called at [/home/piwik/www/demo.piwik.org/plugins/API/API.php:723]
<a href='/4'>#4</a> Piwik_API_API->getProcessedReport(...) called at [:]
<a href='/5'>#5</a> call_user_func_array(...) called at [/home/piwik/www/demo.piwik.org/core/API/Proxy.php:190]
<a href='/6'>#6</a> Piwik_API_Proxy->call(...) called at [/home/piwik/www/demo.piwik.org/core/API/Request.php:128]
<a href='/7'>#7</a> Piwik_API_Request->process(...) called at [/home/piwik/www/demo.piwik.org/plugins/API/Controller.php:27]
<a href='/8'>#8</a> Piwik_API_Controller->index(...) called at [:]
<a href='/9'>#9</a> call_user_func_array(...) called at [/home/piwik/www/demo.piwik.org/core/FrontController.php:138]
<a href='/10'>#10</a> Piwik_FrontController->dispatch(...) called at [/home/piwik/www/demo.piwik.org/index.php:53]

Am I doing something wrong? Please login when calling this method.

"showColumns" doesn't crash but seems to be simply not working. If I unterstand it right, the report below should contain only "nb_visits" column.
http://demo.piwik.org/index.php?idSite=25&date=today&hideMetricsDoc=1&filter_sort_column=nb_visits&showColumns=nb_visits&apiModule=VisitTime&apiAction=getVisitInformationPerServerTime&period=year&filter_limit=30&module=API&format=json&method=API.getProcessedReport&language=en&

When using "showColumns" on reports like VisitsSummary.get I get another error:

Fatal error: Call to a member function getRows() on a non-object in /home/piwik/www/demo.piwik.org/plugins/API/API.php on line 920

http://demo.piwik.org/index.php?idSite=25&date=today&hideMetricsDoc=1&filter_sort_column=nb_visits&showColumns=nb_visits&apiModule=VisitsSummary&apiAction=get&period=year&filter_limit=30&module=API&format=json&method=API.getProcessedReport&language=en

Please also give feedback since which version those parameters are available.

@mattab commented on December 12th 2012 Owner

Thanks for the report. Indeed it would help. Also this could help with SVG Maps which uses metadata API and only need a subset of columns.

hideColumns/showColumns are available since Piwik 1.8.4

@diosmosis commented on December 24th 2012 Member

Hi @tsteur, if you want to show only one or more columns and hide the rest you'd use showColumns=column1,column2. If you wanted to hide one or more columns you'd use hideColumns=column1,column2. The two latter URLs are correct, but their output isn't. I'll look into what's causing the bug(s).

@diosmosis commented on December 24th 2012 Member

(In [7696]) Fixes #3582, fix bug w/ showColumns/hideColumns params where processed metrics that shouldn't have shown in reports were shown.

@diosmosis commented on December 24th 2012 Member

@tsteur I fixed the problem w/ the first two URLs. There's no problem for me w/ the third one (can't reproduce). Let me know if there are any lingering issues.

@mattab commented on December 24th 2012 Owner

Looks good, just one feedback:

  • it should also remove the columns from others keys where they can appear eg. <metricsDocumentation>
@diosmosis commented on December 24th 2012 Member

(In [7697]) Fixes #3582, apply hide/show metrics to metrics docs & metrics in processed reports.

@diosmosis commented on December 24th 2012 Member

(In [7698]) Refs #3582, hide processed metrics w/ showColumns/hideColumns.

@diosmosis commented on December 24th 2012 Member

(In [7699]) Refs #3582, fix bug in last commit.

This Issue was closed on December 24th 2012
Powered by GitHub Issue Mirror