New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Weekly PDF reports not sent on mondays, Monthly reports not sent the 1st of month #1836
Comments
Actually it can get tricky, as the PDF reports should really only be set once all "days" have been finished, ie. in all timezones that the websites are registered. The ideal solution would be to send the PDF reports for each website, as soon as the website day is finished... ie. send 3 reports at midnight UTC for the websites set to UTC, no reports sent until 10AM, and then sent reports to websites set to UTC-10 at 10am... but not necessary to be that precise, the previous solution would be easier! So I think the simpler fix would be to setHour( LATEST HOUR where a day finishes for ANY website registered), so all PDF reports are sent after we are confident that all days are finished... Does it make sense? |
Note: Monthly reports should be similarly sent the first day of the month (as soon as all months are finished, in the websites timezones) |
Correct me if I'm wrong. So that all websites will have reached their local 00h00 when the report is sent, setHour should be set at : (00h00 + time zone number - time zone number of all sites), Server local time |
With this equation, in the following case, the report would be (correctly) sent the last day of the month instead of the first :
The report could correctly be sent the last day of the month at 10AM from the Piwik Server because the site using UTC +15 will have already finished its day. Should we implement it like that or simply send the report at 00h00 Piwik server time ? The algorithm would then become :
|
The server timezone is always set to UTC (piwik forces UTC in index.php) Interesting file to look at Date/timezone manipulation helpers is tests/core/Date.test.php A slightly similar function to look at also is setMinMaxDateAcrossWebsites in Multisites/controller Finally, to get all websites and then the timezone, you can use the SitesManager_API.getSitesWithAtLeastViewAccess function (as the script will run as super user). It is not the best performance wise (each call to runTasks() will result in selecting all websites and comparing all timezones), but it will work fine. To make it fast for a Piwik server with thousands of websites, we could for example record, on each website update, the earliest and latest timezone available in the _option table (but this will be a feature request when we hit problems, not yet the case :) |
I was indeed wondering if Piwik forces UTC 0, thanks for clarifying. This issue, still applies though. |
Should CodeAdminHome scheduled task be updated as well to be triggered the first day of the month ? |
Yes maybe this task could be ran 1st day of month as well. |
Interesting idea. In that case, for API consistency, we need to set defaults for Daily and Weekly as well. |
Defaults should be:
|
(In [3387]) refs #1836 comment:12 - set defaults to setHour & setDay, updating unit tests |
Here is a working proposal to set the correct hour to the scheduled tasks. If you have 3 sites with UTC+1, UTC-11, UTC-8.5, it will
If you have 3 sites with UTC+1, UTC+10, UTC+15, it will
If you have 1 site with UTC-8.5, it will
|
what is the status of the ticket? can you please post a patch, or commit if you're confident |
(In [3524]) fixed #1836 - sets hour on scheduled tasks to wait for end of period for all configured websites timezone, should be refactored in utility class |
As reported on the forum, the pdf plugin needs to be updated to force weekly reports to be sent on mondays.
In plugins/PDFReports/PDFReports.
TODO: Use setDay(1) on Piwik_ScheduledTime_Weekly.
Should we set a specific hour aswell ?
The text was updated successfully, but these errors were encountered: