Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Date Range is not correct recognized in Metadata API #3074

Closed
tsteur opened this Issue · 11 comments

4 participants

@tsteur
Owner

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
Owner

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
Collaborator

I cannot reproduce that. maybe it is already fixed?

@tsteur
Owner

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
Owner

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

@diosmosis
Collaborator

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
Owner

Maybe also similar / related to #3782

@tsteur
Owner

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

@tsteur
Owner

In 57377fa: refs #3074 fix some tests

@tsteur
Owner

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

@tsteur
Owner

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

@tsteur
Owner

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

@tsteur tsteur added this to the 2.0 - Piwik 2.0 milestone
@mattab mattab was assigned by tsteur
@sabl0r sabl0r referenced this issue from a commit in sabl0r/piwik
@tsteur tsteur refs #3074 added two test cases to prove range returns wrong dates un…
…der circumstances
e0df029
@sabl0r sabl0r referenced this issue from a commit in sabl0r/piwik
@tsteur tsteur refs #3074 fix range date is sometimes wrong 4e985d2
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.