devxy/build-cran-binaries
Watch
1
0
Fork
You've already forked build-cran-binaries
0

feat(stats): publish per-package download statistics

Write one JSON file per package to stats/packages/<name>.json with its
daily series and its versions, distributions, R versions and
architectures for 7 days, 30 days and all time, for the package view
of the rpkgs.com dashboard.

- Add distinct package and byte counts to each window in downloads.json.
- Add breakdowns for every window as breakdownsByWindow, keeping
  breakdowns as the 30-day set for existing readers.
- Upload package files before the main file and purge them with one
  wildcard purge.
This commit is contained in:
Patrick Schratz 2026-11-14 13:29:58 +01:00
commit 06afded1fe

View file

@ -8,6 +8,7 @@ The `download-stats` pipeline runs it every hour.
1. `collect.ts` reads the last 70 hours of access logs from the Bunny Logging API v2 and inserts each request into `download_stats.events` in the build metadata database.
2. `classify.ts` derives what each request was (package download, index fetch, redirect, probe, noise) from its path, status and User-Agent.
3. `publish.ts` aggregates the events into `stats/downloads.json` in the binaries bucket and purges its CDN copy, so it is served at <https://cran.rpkgs.com/stats/downloads.json>.
4. `packages.ts` writes one file per package, `stats/packages/<name>.json`, with its daily series and its versions, distributions, R versions and architectures for each window. The dashboard fetches one only when that package is opened, so the main file does not grow with the number of packages.
Bunny keeps access logs for three days.
Each hourly run re-reads almost all of that window, and events are keyed by Bunny's request id, so re-reading never double counts and up to two days of failed runs lose nothing.