packagist icon indicating copy to clipboard operation
packagist copied to clipboard

Tweak how daily and monthly download stats are calculated

Open javiereguiluz opened this issue 2 years ago • 0 comments

On Mondays, download stats given by Packagist API (e.g. https://packagist.org/packages/symfony/console.json) are "wrong" because it mostly takes into account the downloads of the previous days, which are the weekend days.

For your consideration, I propose to tweak how these stats are calculated:

  • Daily downloads:
    • Ignore the current day downloads because the day isn't over yet
    • Take the downloads of the prior 30 days and calculate the average
  • Monthly downloads:
    • Ignore the current month downloads because the month isn't over yet
    • Take the downloads of the prior 6 months and calculate the average
    • 6 months would be long enough to avoid distortion from special holidays and short enough to give a realistic view of recent package downloads

I looked into this class (https://github.com/composer/packagist/blob/main/src/Model/DownloadManager.php) to try to propose a pull request, but I don't work with Redis and I'm not sure how to tweak things.

Thanks!

javiereguiluz avatar May 02 '22 08:05 javiereguiluz