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
npm total statistic is wrong #1278
Comments
Limits section in NPM package download counts API states:
This case is similar to #672 I can see two options:
|
Thanks for the quick response! I think that loading of all data in 2 (or later more) requests, would be mostly interesting for the users. There are exist already the "last year" button https://img.shields.io/npm/dy/express.svg, which corresponds the request https://api.npmjs.org/downloads/point/2016-11-20:2017-11-20/express. I don't think that "downloads in the last 18 months" will be more interesting from the users point of view as already existing "last year" button. The Limits says
Then one could divide the time interval from today till "2015-01-10" in 18 months intervals and makes the sum of all results. It's nor really more complex as implementing of one requests. Currently it's enough 2 requests (like https://api.npmjs.org/downloads/point/2015-01-10:2016-06-30/express and https://api.npmjs.org/downloads/point/2016-07-01:2017-11-20/express), but later 3 or more requests would be required. One could add optionally the tooltip (like you suggested) that the total count take in considerations only the interval starting with January 10, 2015. |
Good points all around. Some other options we could consider:
|
The value of the badge "total npm downloads" shows wrong value. I posted the bug report as [the issue #1278](badges/shields#1278). At least till the problem is not fix I'll use "npm downloads per month" badge.
Hey there! I'm just seeing this for I think making a couple requests (I'm aware it will be one more request per 18 months) or caching historical data is preferable to inaccurate reports. |
Making multiple requests for every request is not a great option. We do need the data to be cached, or prefetched, in some way. |
Having an incorrect count is probably a worse option... |
Just wanted to put out there that Shields is a community project, and that means you can help make this happen! 👐
These approaches, for example, could easily be taken on independently of Shields. We could definitely point our implementations at them. Our maintainer team is happy to provide guidance on the API! |
NPM and Shields.io are having bugs with their download stats and it's throwing our stats out of wack: * badges/shields#1278
I'll explain the problem on an example. https://shields.io/ displays the statistic of "express" package as an example. It shows the value 195M (see https://img.shields.io/npm/dt/express.svg) as the total statistic of express downloads.
The npm-provider.js uses package download counts API to get NPM download statistic via request like
One can easy verify that https://api.npmjs.org/downloads/point/2015-01-01:2017-12-31/express returns (today)
and 194785100 corresponds 195M displayed in the badge https://img.shields.io/npm/dt/express.svg. The problem is that one supposes that "2016-05-20" is really starting point of all downloads. On the other side one can make another request https://api.npmjs.org/downloads/point/2014-01-01:2016-05-19/express, which returns
(where "2016-05-19" is the date previous to "2016-05-20" from the
"start"
of the previous response). One more request https://api.npmjs.org/downloads/point/2014-01-01:2015-01-10/express returns0 downloads. As the result, the total downloads in the interval from 2014-01-01 till today would be 194785100 + 57328706 = 252113806 and 252M instead of 195M would be the correct number of downloads of express.
As the reference one can open the page https://npm-stat.com/charts.html?package=express&from=2014-01-01&to=2017-11-19 and see exactly the same value:
The text was updated successfully, but these errors were encountered: