matomo-org / matomo

Empowering People Ethically with the leading open source alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. Liberating Web Analytics. Star us on Github? +1. And we love Pull Requests!
https://matomo.org/
GNU General Public License v3.0
19.79k stars 2.63k forks source link

Image graph; idSite=all error #7566

Open crashkonijn opened 9 years ago

crashkonijn commented 9 years ago

Hello,

I was trying to get an image graph of all my websites at once, and this gave me the following error: (this is from piwik's own demo site)

<b>Fatal error</b>:  Call to undefined method Piwik\DataTable\Map::getMetadata() in <b>/home/piwik-demo/www/demo.piwik.org/plugins/API/ProcessedReport.php</b> on line <b>543</b><br />
<br />
<b>Fatal error</b>:  Uncaught exception 'Exception' with message 'A fatal error occurred.' in /home/piwik-demo/www/demo.piwik.org/plugins/CorePluginsAdmin/Controller.php:371
Stack trace:
#0 [internal function]: Piwik\Plugins\CorePluginsAdmin\Controller-&gt;safemode(Array)
#1 /home/piwik-demo/www/demo.piwik.org/core/FrontController.php(530): call_user_func_array(Array, Array)
#2 /home/piwik-demo/www/demo.piwik.org/core/FrontController.php(96): Piwik\FrontController-&gt;doDispatch('CorePluginsAdmi...', 'safemode', Array)
#3 /home/piwik-demo/www/demo.piwik.org/core/FrontController.php(183): Piwik\FrontController-&gt;dispatch('CorePluginsAdmi...', 'safemode', Array)
#4 [internal function]: Piwik\FrontController::triggerSafeModeWhenError()
#5 {main}
  thrown in <b>/home/piwik-demo/www/demo.piwik.org/plugins/CorePluginsAdmin/Controller.php</b> on line <b>371</b><br />

http://demo.piwik.org/index.php?module=API&method=ImageGraph.get&idSite=all&apiModule=VisitsSummary&apiAction=get&token_auth=anonymous&graphType=evolution&period=day&date=previous30&width=500&height=250

The same happens if I try to set idSite to multiple id's.

Is there another way to achieve this?

Kind regards,

Peter Klooster

mattab commented 9 years ago

Hi Peter,

Thanks for the suggestion. It's currently not support to draw several websites on the ImageGraph but for sure it would be a nice new feature!

saleemkce commented 9 years ago

@crashkonijn @mattab , I am working in this issue to make sure that the image graph render for multiple sites as comma separated values as well as 'idSite=all'. Please stay tuned for its availability.

crashkonijn commented 9 years ago

Awesome, thankyou!

The only difference with what I expected to get was that I assumed to get back one image with multiple sites shown on it. (Very handy for an overview of all sites). But this will do for now.

Thanks again!

saleemkce commented 9 years ago

@mattab Generally speaking, image graph generation is a kind of memory and time consuming task and so having the facility to view all idSite's graph in one page is a very nice feature. But the concern may be that if the user manages more than 10 or 20 sites, it will take huge amount of time for graph generation. It may even cause script execution time out. So do we may need to limit the number of image graphs generated even if idSite=all is set? If so, I assume setting the limit to either 10 or 15 consolidated image graphs per user would be reasonable. What do you think? do we need to have limits here?

crashkonijn commented 9 years ago

@saleemkce I've got no idea how long the generation of such image is, but I'd assume that more then 5-10 in one image wouldn't work anyway. If a person has more then the maximum amount of websites, what would you suggest happens then?

I think you could ether return more images or return just the maximum, however if I send for id=all I'd expect them all to be returned. As well as when I ask for an img that I get one, not a bunch of them. (this would break my code at least)

Is there a way to detect the amount of time a script took and stop it just before the maximum? Because it differs per server how much sites you would be able to handle before going over the limit right?

saleemkce commented 9 years ago

@crashkonijn, @mattab

crashkonijn commented 9 years ago

@saleemkce @mattab

I would suggest the following:

I do agree with testing what the right maximum amount would be. However a huge piwik database on a slow server could also collapse with one server, and a heavy server with a lot of smaller piwik databases might just do just fine generating an image (I suppose). Would it be possible to create a setting for this and create an error log message if the requested image is probably taking to much time? This could warn a developer to change his or her code to request only a couple sites at the time. Leave the developers that use this option with some responsibility :)