A possible bug in _parseUrl()
michael2h4ng opened this issue · 2 comments
michael2h4ng commented
The code used to append the parameter date
looks like this.
if ($this->_period != self::PERIOD_RANGE) {
$params = $params + array(
'date' => $this->_date,
);
} else {
$params = $params + array(
'date' => $this->_rangeStart . ',' . $this->_rangeEnd,
);
}
However, there are actually 3 posibilities:
period = range
ANDdate = date1, date2
. In this case, the API returns all data between the 2 dates as one data entry. For example: http://demo.piwik.org/?module=API&method=VisitsSummary.get&idSite=7&period=range&date=2015-2-1,today&format=JSON&token_auth=anonymousperiod = day
ANDdate = date1
. This returns 1 data entry for the given date. For example: http://demo.piwik.org/?module=API&method=VisitsSummary.get&idSite=7&period=day&date=today&format=JSON&token_auth=anonymousperiod = day
ANDdate = date1, date2
. This should return separate data entries for each day between the 2 dates. For example: http://demo.piwik.org/?module=API&method=VisitsSummary.get&idSite=7&period=day&date=2015-2-1,today&format=JSON&token_auth=anonymous And we can even have something like this: http://demo.piwik.org/?module=API&method=VisitsSummary.get&idSite=7&period=month&date=2014-2-1,today&format=JSON&token_auth=anonymous
Currently, _parseUrl() only considers the first 2 situations. Can we implement the last situation? It's extremely useful when people want to visualize visits data over time.
Thanks.
monomichael commented
I opened PR #15 for this issue
thelfensdrfer commented
Thank you, i was not aware of the third possibility.