Skip to content
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

'today' and 'yesterday' return different results than using todays date and yesterdays date #10099

Open
gleasj opened this issue Apr 28, 2016 · 6 comments
Labels
Bug For errors / faults / flaws / inconsistencies etc.

Comments

@gleasj
Copy link

gleasj commented Apr 28, 2016

When pulling a report using the API (and python), the results that come back are inconsistent.

  • I ask for a filtered result set using 'today' and get correct results
  • I ask for the same set using 2016-04-27 and get incorrect results (from 4/27 and 4/26)
  • I ask for a set using 'yesterday' and get incorrect results (the same set as using todays date)
  • I ask for a set using 2016-04-26 and get correct results

There seems to be something wrong with the date conversion.

Here is the query I am using, and the results that come back:

url = 'http://atlasco.piwik.pro/?module=API'
url += '&method=Live.getLastVisitsDetails'
url += '&doNotFetchActions=true'
url += '&idSite=3'
url += '&period=day'
url += '&date=' + date
url += '&segment=visitConvertedGoalId==12;customVariableName3==Regular%20User'
url += '&filter_limit=-1'
url += '&showColumns=userId,serverDatePretty,serverTimePretty'
url += '&format=json'
url += '&token_auth=###############' # token from piwik
C:\Users\Jon> piwik_report.py today
New registrations for today : 3
### userA ###@gmail.com Wednesday, April 27, 2016 18:48:26
### userB ### Wednesday, April 27, 2016 14:00:25
### userC ### Wednesday, April 27, 2016 11:28:46

C:\Users\Jon> piwik_report.py 2016-04-27
New registrations for 2016-04-27 : 4
### userA ### Wednesday, April 27, 2016 18:48:26
### userB ### Wednesday, April 27, 2016 14:00:25
### userC ### Wednesday, April 27, 2016 11:28:46
### userD ### Tuesday, April 26, 2016 11:44:10

C:\Users\Jon> piwik_report.py yesterday
New registrations for yesterday : 4
### userA ### Wednesday, April 27, 2016 18:48:26
### userB ### Wednesday, April 27, 2016 14:00:25
### userC ### Wednesday, April 27, 2016 11:28:46
### userD ### Tuesday, April 26, 2016 11:44:10

C:\Users\Jon> piwik_report.py 2016-04-26
New registrations for 2016-04-26 : 1
### userD ### Tuesday, April 26, 2016 11:44:10
@tsteur
Copy link
Member

tsteur commented May 1, 2016

Did you execute this script on "April 27th"? What's your timezone for that site?

Btw: The displayed dates should be UTC

I think this might be related to #8761 and it may be related to https://github.com/piwik/piwik/blob/2.16.1/plugins/Live/Model.php#L485-L490

Can you maybe comment the line in https://github.com/piwik/piwik/blob/2.16.1/plugins/Live/Model.php#L489 and see if it works afterwards?

@gleasj
Copy link
Author

gleasj commented May 3, 2016

This was executed on April 27, at approximately 11:00pm - Pacific Time.

If the displayed dates are UTC, then the input should also be UTC - otherwise it is really confusing trying to pull info out. A better option would be to be able to set local time and do everything that way - cause that is how humans think)

I am not running piwik on our own server, so I cannot comment those lines out - thnaks.

@tsteur
Copy link
Member

tsteur commented May 3, 2016

The input basically means today in the website's timezone. The property you are likely printing here is serverTimePretty which basically means UTC but doesn't say it which is not ideal indeed.

@tsteur tsteur closed this as completed May 3, 2016
@tsteur tsteur added the answered For when a question was asked and we referred to forum or answered it. label May 3, 2016
@gleasj
Copy link
Author

gleasj commented May 3, 2016

I think this should be re-opened as a bug. Regardless of whether it is printing UTC time or not, 'today' is reporting some of the same things as 'yesterday'. and 04/27 is reporting some of the same things as 04/26.

The report for those time periods should be mutually exclusive. Something cannot be both yesterday and today, or 4/26 and 4/27.

@tsteur
Copy link
Member

tsteur commented May 5, 2016

The report for those time periods should be mutually exclusive. Something cannot be both yesterday and today, or 4/26 and 4/27.

that's very true. Sorry for closing it, I didn't really realize that point.

Re the API and the column name we likely cannot really change it as it would break many APIs etc.

@tsteur tsteur reopened this May 5, 2016
@tsteur tsteur added Bug For errors / faults / flaws / inconsistencies etc. and removed answered For when a question was asked and we referred to forum or answered it. labels May 5, 2016
@mattab
Copy link
Member

mattab commented May 27, 2016

Thanks for the report @gleasj

Note: this error should be restricted to the API method=Live.getLastVisitsDetails and maybe other Live.* APIs but as for the other plugins APIs it should work as expected.

@mattab mattab added this to the 2.16.x (LTS) milestone Jul 14, 2016
@mattab mattab modified the milestones: 2.16.x (LTS), Mid term Aug 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
Development

No branches or pull requests

3 participants