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

Date Range is not correct recognized in Metadata API #3074

Closed
tsteur opened this issue Mar 28, 2012 · 11 comments
Closed

Date Range is not correct recognized in Metadata API #3074

tsteur opened this issue Mar 28, 2012 · 11 comments
Assignees
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Milestone

Comments

@tsteur
Copy link
Member

tsteur commented Mar 28, 2012

When using period=range and the "To" date is set to today, the API sometimes returns a wrong date. Example:

At March 24 I tried to call this url:

http://demo.piwik.org/index.php?idSite=7&date=2012-03-22,2012-03-24&filter_sort_column=nb_visits&apiModule=VisitsSummary&apiAction=get&period=range&filter_limit=30&module=API&token_auth=anonymous&format=json&method=API.getProcessedReport&language=de

I got the following response
{"website":"Piwik Forums","prettyDate":"19 M\u00e4r 12 - 24 M\u00e4r 12","metadata":{"category":"Besucher\u00fcberblick","name":"Besucher\u00fcberblick","module":"VisitsSummary","action":"get","metrics":{"nb_uniq_visitors":"Eindeutige Besucher","nb_visits":"Besuche","nb_actions":"Aktionen","nb_actions_per_visit":"Aktionen pro Besuch","bounce_rate":"Absprungsrate","avg_time_on_site":"Durchschnittliche Besuchszeit (in Sekunden)","max_actions":"Maximale Aktionen pro Besuch"},"metricsDocumentation":{"nb_visits":"Wenn ein Besucher zum ersten Mal die Webseite besucht oder seit dem letzen Seitenaufruf mehr als 30 Minuten vergangen sind, wird dies als neuer Besuch gewertet.","nb_uniq_visitors":"Die Anzahl der eindeutigen Besucher auf der Webseite. Jeder Benutzer wird nur einmal gez\u00e4hlt, auch wenn er die Webseite mehrmals t\u00e4glich besucht hat.","nb_actions":"Die Anzahl der Aktionen, die ein Besucher durchgef\u00fchrt hat. Aktionen sind Seitenansichten, Downloads und der Aufruf von externen Links.","nb_actions_per_visit":"Die durchschnittliche Anzahl der Aktionen (Seitenaufrufe, Downloads oder Outlinks), die w\u00e4hrend der Besuche durchgef\u00fchrt wurden.","avg_time_on_site":"Durchschnittsl\u00e4nge eines Besuches.","bounce_rate":"Der Anteil der Besuche, bei denen nur eine Seite aufgerufen wurde. Dies bedeutet, dass der Besucher die Website auf der Eingangsseite sofort wieder verlassen hat.","conversion_rate":"Prozentsatz der Besucher, die ein Zeil erreicht haben.","avg_time_on_page":"Die durchschnittliche Besuchdauer einer Seite (nur die einzelne Seite, nicht die gesamte Webseite)","nb_hits":"Die Anzahl, wie h\u00e4ufig diese Seite besucht wurde.","exit_rate":"Der Anteil der Besuche, welche die Webseite nach dieser Seite verlassen haben."},"imageGraphUrl":"index.php?module=API&method=ImageGraph.get&idSite=7&apiModule=VisitsSummary&apiAction=get&token_auth=anonymous&period=day&date=2012-03-22,2012-03-24","uniqueId":"VisitsSummary_get"},"columns":{"nb_uniq_visitors":"Eindeutige Besucher","nb_visits":"Besuche","nb_actions":"Aktionen","nb_actions_per_visit":"Aktionen pro Besuch","bounce_rate":"Absprungsrate","avg_time_on_site":"Durchschnittliche Besuchszeit (in Sekunden)","max_actions":"Maximale Aktionen pro Besuch"},"reportData":{"nb_visits":"5505","nb_actions":"14058","max_actions":"112","bounce_rate":"64%","nb_actions_per_visit":2.6,"avg_time_on_site":"00:02:56","nb_uniq_visitors":0},"reportMetadata":[],"timerMillis":"42"}

Note the Date "19 M\u00e4r 12 - 24 M\u00e4r 12". I've requested 22-24 but it returns 19-24.

Today, I tried to call this url:
http://demo.piwik.org/index.php?idSite=7&date=2012-03-27,2012-03-28&filter_sort_column=nb_visits&apiModule=VisitsSummary&apiAction=get&period=range&filter_limit=30&module=API&token_auth=anonymous&format=json&method=API.getProcessedReport&language=de

and it returns the date for "26 M\u00e4r 12 - 28 M\u00e4r 12"

Is this a bug or am I doing something wrong? I implemented the date range picker into Piwik Mobile. If it's a bug, it would be great to see a fix in the next release.

@tsteur
Copy link
Member Author

tsteur commented May 7, 2012

I guess the bug is somewhere here https://github.com/piwik/piwik/blob/master/core/Period/Range.php#L262

To reproduce just open the url (replace domain + idsite) and switch the date to March 24 before: e.g.

sudo date -s "24 MAR 2012 10:22:00"

@sgiehl
Copy link
Member

sgiehl commented Aug 10, 2012

I cannot reproduce that. maybe it is already fixed?

@tsteur
Copy link
Member Author

tsteur commented Aug 11, 2012

It is still reproduceable...

As mentioned you have to change the date and you should make sure the date is not changed by the system while testing (for example by ntpd)

@mattab
Copy link
Member

mattab commented Aug 11, 2012

Increasing priority of this bug, which was reported in the forum too

@diosmosis
Copy link
Member

Note for @matt: this bug is caused by something in the Piwik_Period_Range::processOptimalSubperiods function. I think you said you were going to clean this code up (I couldn't figure out what the optimizations were)? Anyway, #2270 requires a change to the same method, so I think they can both be done at the same time.

@mattab
Copy link
Member

mattab commented Mar 11, 2013

Maybe also similar / related to #3782

@tsteur
Copy link
Member Author

tsteur commented Oct 30, 2013

In 83cfb4c: refs #3074 could fix two issues in case enddate is in the future or enddate is the end of the week

@tsteur
Copy link
Member Author

tsteur commented Oct 30, 2013

In 57377fa: refs #3074 fix some tests

@tsteur
Copy link
Member Author

tsteur commented Oct 30, 2013

In ef830ca: refs #3074 reformat code again to look like before

@tsteur
Copy link
Member Author

tsteur commented Oct 30, 2013

In e0df029: refs #3074 added two test cases to prove range returns wrong dates under circumstances

@tsteur
Copy link
Member Author

tsteur commented Oct 31, 2013

In 4e985d2: refs #3074 fix range date is sometimes wrong

@tsteur tsteur added this to the 2.0 - Piwik 2.0 milestone Jul 8, 2014
sabl0r pushed a commit to sabl0r/piwik that referenced this issue Sep 23, 2014
sabl0r pushed a commit to sabl0r/piwik that referenced this issue Sep 23, 2014
This issue was closed.
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

4 participants