pvorb / npm-stat.com

download statistics for npm packages
https://npm-stat.com/
Apache License 2.0
1.17k stars 51 forks source link

Feature: downloads leaderboard #73

Open epoberezkin opened 5 years ago

epoberezkin commented 5 years ago

@pvorb The idea is to show the leaderboard on the homepage without entering any packages. Could be top 10 packages in the last week, month, year. It could be updated daily if you have concerns that it is a heavy query to hit on each home page load. It should be relatively straightforward, unless I am missing something.

Given that downloads leaderboard doesn't exist anywhere else it could give you some traffic boost.

epoberezkin commented 5 years ago

Also could be the same for authors (I forgot that you can compare authors stats :)

epoberezkin commented 5 years ago

Found this: https://github.com/pvorb/npm-stat.com/issues/35 I think there is a database now?

pvorb commented 5 years ago

There is a database right now, but it only serves as a cache. The problem is that I don't download the numbers for all the packages every day, but only those that are requested. The numbers are then persisted and won't be downloaded again.

For the feature you requested, the first thing to do would be to get the list of all packages every day, and then download the counts for every package.

While it sounds cool, I don't think I'll implement this feature. There doesn't seem to be a good API on npm's end to get the names of every package. If there was some sort of daily dump it could be easily done.

epoberezkin commented 5 years ago

I see. But it should be relatively simple to see and maintain top 10 of all requested by updating daily top 100 of all requested. A bit less simple though :)

pvorb commented 5 years ago

But if it only included the top X of requested packages, how helpful would that statistic be?

epoberezkin commented 5 years ago

The idea is that sooner or later most important packages will be requested. I meant "show top 10 of top 100 ever requested packages"

epoberezkin commented 5 years ago

So trying to have the full list of all packages, you'll let the visitors to create the lists of important packages and updating them daily. Or maybe a good start could be to download stats of these packages: https://gist.github.com/anvaka/8e8fa57c7ee1350e3491 and then maintain them daily (I think you can get weekly, monthly and annual in one API call each, you don't need as much calls as to do the chart.

pvorb commented 5 years ago

There's a complete list of all packages at https://replicate.npmjs.com/_all_docs. Maybe I can use that for downloading all package stats in a daily cron job...