Open OlegKi opened 7 years ago
I still didn't get any answer. Thus I analysed the problem additionally. I suppose that you use package download counts API
GET https://api.npmjs.org/downloads/point/{period}[/{package}]
to get the statistics information. The problem, which I found is: the API restricts the time interval and one have to makes multiple requests to get correct answer. I try to explain the problem on the example, posted in my previous comment. If we would use https://api.npmjs.org/downloads/point/2015-01-01:2017-11-15/free-jqgrid we get the following JSON response:
{"downloads":9962,"start":"2016-05-15","end":"2017-11-15","package":"free-jqgrid"}
It would be wrong to suppose that it was no downloads before 2016-05-15. The request https://api.npmjs.org/downloads/point/2015-01-01:2016-05-14/free-jqgrid returns
{"downloads":2587,"start":"2015-01-10","end":"2016-05-14","package":"free-jqgrid"}
And then the correct value of total downloads in the interval from 2015-01-01 till 2017-11-15 would be the value 9962+2587=12549, which corresponds the value displayed on https://npm-stat.com/charts.html?package=free-jqgrid&from=2015-03-05&to=2017-11-15.
I know additionally, that the package "free-jqgrid" was first released at 2015-03-04 (see https://github.com/free-jqgrid/jqGrid/tree/v4.8.0) in the version 4.8.0. Thus I can be sure that "2015-03-05" was really first download way of the package. The request https://api.npmjs.org/downloads/point/2015-01-01:2015-03-04/free-jqgrid, which returns
{"downloads":0,"start":"2015-01-10","end":"2015-03-04","package":"free-jqgrid"}
and https://api.npmjs.org/downloads/point/2015-03-05:2015-03-05/free-jqgrid, which returns
{"downloads":28,"start":"2015-03-05","end":"2015-03-05","package":"free-jqgrid"}
confirm me that "2015-03-05" would be really the first download day on the package.
My problem is that I display in the README displays the image https://img.shields.io/npm/dt/free-jqgrid.svg?style=flat-square with wrong statistic value. I'd like to fix the problem. I suppose that wrong value come from your npm-stats-www. Is it so? Or I should post additional separate pull request to another repository.
Hi, thanks for digging into this. I think you're right, for fixing this we should make multiple requests to have accurate counts. The bug started showing when npm changed its api for limiting their date interval. If you would be able to help with that, it would be great.
In regards of the shields badges, I am not sure they use this repo - do you know if their sourcecode is open?
@matteofigus Thanks for the feedback. The shields badges will be managed by separate GitHub repository. I posted the issue to the corresponding team too. Currently one plans to make multiple requests to fix the problem, but the corresponding changes are not yet implemented.
Could you explain me why http://npm-stats.com/~packages/free-jqgrid displays not full download statistic? The results corresponds the statistic starting with 2016-05-15 only instead of 2015-03-05 (the day after the first publishing). One can see full download statistic on https://npm-stat.com/charts.html?package=free-jqgrid&from=2015-03-05&to=2017-11-15, but the results of http://npm-stats.com/~packages/free-jqgrid corresponds https://npm-stat.com/charts.html?package=free-jqgrid&from=2016-05-15&to=2017-11-15 only.
Thank you in advance!