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

Live.getLastVisitsDetails does not accept period=day&date=last10 #9840

Open
tsteur opened this issue Feb 24, 2016 · 8 comments
Open

Live.getLastVisitsDetails does not accept period=day&date=last10 #9840

tsteur opened this issue Feb 24, 2016 · 8 comments
Labels
Bug For errors / faults / flaws / inconsistencies etc.

Comments

@tsteur
Copy link
Member

tsteur commented Feb 24, 2016

See #9798 (comment)

Can be reproduced with this URL: http://demo.piwik.org/?module=API&method=Live.getLastVisitsDetails&idSite=7&period=day&date=last10&format=json&token_auth=anonymous&translateColumnNames=1

In the example there is period=day&date=last10 and it results in an error

Error: Date format must be: YYYY-MM-DD, or 'today' or 'yesterday' or any keyword supported by the strtotime function (see http://php.net/strtotime for more information):

@tsteur tsteur added the Bug For errors / faults / flaws / inconsistencies etc. label Feb 24, 2016
@oleg-sh
Copy link

oleg-sh commented Feb 24, 2016

Even if I change the URL to date=today I get the following error:
"Error: RSS feeds can be generated for one specific website &idSite=X.
Please specify only one idSite or consider using &format=XML instead."
Changing idSite after that doesn't seem to help.

@tsteur
Copy link
Member Author

tsteur commented Feb 24, 2016

For RSS it's normal, switch format to XML and they bug is still the same

@mattab mattab added this to the Mid term milestone Mar 31, 2016
@RMastop
Copy link
Contributor

RMastop commented Jul 5, 2016

Found another issue regarding strtotime
I use it to get the data for the past 12 months.

Steps to reproduce:
To get the data for the same month last year, I use this:
module=API&method=API.get&format=CSV&idSite=37&period=month&date=last%20year
To get the data for last month I use this:
module=API&method=API.get&format=CSV&idSite=37&period=month&date=last%20month
To get the data for all months from last year to last month I tried to use this:
module=API&method=API.get&format=CSV&idSite=37&period=month&date=last%20year,last%20month
But it fails.
When I use
module=API&method=API.get&format=CSV&idSite=37&period=month&date=2015-07-01,2016-06-01
the data is available.

Another example is the following:
module=API&method=API.get&format=CSV&idSite=37&period=day&date=previous6
gets me the data of the previous 6 days splitted per day (excluding today)

One would think the API following call: module=API&method=API.get&format=CSV&idSite=37&period=week&date=previous6
would return the data of the previous 6 weeks, splitted per week
and
module=API&method=API.get&format=CSV&idSite=37&period=month&date=previous6
would return the data of the previous 6 months, splitted by month.
However it does not.

@tsteur
Copy link
Member Author

tsteur commented Jul 5, 2016

FYI: AFAIK last%20month and last%20year are not supported formats. See http://developer.piwik.org/api-reference/reporting-api under date. As magic keywords only today and yesterday are supported as well as eg last6 and previous6.

There it says re previous6:

previousX returns the last X periods before today (eg. &date=last52&period=week will return an entry for each of the 52 weeks before this week). This is relative to the website timezone.

And it works like this when I apply it eg here: http://demo.piwik.org/?module=API&method=API.get&format=JSON&idSite=7&period=week&date=previous6 It seems to be only limited for CSV/TSV export as this returns an error see http://demo.piwik.org/?module=API&method=API.get&format=CSV&idSite=7&period=week&date=previous6 . It is failing here: https://github.com/piwik/piwik/blob/2.16.2-b2/core/DataTable/Renderer/Csv.php#L309 . I have issued a pull request in #10273 to fix it but I cannot promise it'll be merged as some other tests may fail.

@RMastop
Copy link
Contributor

RMastop commented Jul 5, 2016

Yeah, I know I'm pushing it to hard and over it's limit. ;)

I'm using last%month and last%20year for a long time now, but never for ranges. oh... and never on the 31st of a month, or the last week of march, because of the month calculation bug that exists in strtotime.

If you look at strtotime page that is referenced by the error page that shows up, a lot more 'magic keywords' are available. I was hoping it could be added without to much of a hassle.

To be able to use previous6 in months and weeks in csv export would be really helpful. and it would solve my issue, without the use of unsupported magic keywords.

@mattab mattab modified the milestones: 2.16.2, Mid term Jul 8, 2016
@mattab
Copy link
Member

mattab commented Jul 12, 2016

After deploying the next beta/rc to demo, I will confirm this bug is fixed and close the issue then.

@mattab mattab self-assigned this Jul 12, 2016
@tsteur
Copy link
Member Author

tsteur commented Jul 12, 2016

be aware that I did not provide a fix for this issue, only for the reported CSV issue

@mattab mattab modified the milestones: Long term, 2.16.2, Mid term Jul 12, 2016
@mstenz
Copy link

mstenz commented Feb 22, 2018

please note that this similar issue also happen when you have set the time to monthly and then click from the "All Websites" on a Website link. As this is made from the UI automatically it should work without error.

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

5 participants