devxy/build-cran-binaries
Watch
1
0
Fork
You've already forked build-cran-binaries
0
build-cran-binaries/local/archive-missed-pkgs.R
pat-s 2614d40bd9 feat(stats): collect CDN access logs and publish download statistics
Add an hourly download-stats pipeline that reads the cran-rpkgs Bunny
access logs into a download_stats schema in the build metadata database
and publishes aggregated counts to /stats/downloads.json for the
rpkgs.com /stats page.

- Classify each request (download, index, redirect reason, probe, noise)
  mirroring the edge router, and split cloud/CI networks from the rest.
- De-duplicate downloads per client, package version and day, and key
  clients on a salted HMAC so no IP is stored or published.
- Exclude our own CI runners and record run windows to show gaps.
- Declare the zone's logging settings and allow CORS for JSON.
2026-11-14 13:02:53 +01:00

44 lines
1.4 KiB
R

### Scope: Archive packages that have more than one entry in repository root
library(bincraft)
s3fs::s3_file_system(
aws_access_key_id = Sys.getenv("HETZNER_S3_ACCESS_KEY_K3S"),
aws_secret_access_key = Sys.getenv("HETZNER_S3_SECRET_KEY_K3S"),
endpoint = "https://hel1.your-objectstorage.com",
region_name = "hel1",
refresh = T
)
arch <- "arm64"
os <- "alpine321"
files <- s3fs::s3_dir_ls(sprintf(
"devxy-r-package-binaries-hel1/%s/%s/latest/src/contrib",
arch,
os
))
length(unique(sapply(strsplit(basename(files), "_"), function(x) x[1])))
non_archived <- unique(sapply(strsplit(basename(files), "_"), function(x) {
x[1]
})[duplicated(sapply(strsplit(basename(files), "_"), function(x) x[1]))])
# RInno is not built because it only exists for Windows
non_archived <- setdiff(non_archived, "RInno")
# future::plan("sequential", workers = 8)
future::plan("sequential", workers = 1)
# future.apply::future_lapply(non_archived, function(x) archive_package(x, codename = os, arch = arch))
lapply(non_archived, function(x) {
archive_package(
x,
codename = os,
arch = arch,
s3_region = "hel1",
s3_endpoint = "https://hel1.your-objectstorage.com",
s3_bucket = "devxy-r-package-binaries-hel1",
s3_access_key_id = Sys.getenv(
"HETZNER_S3_ACCESS_KEY_K3S",
s3_secret_access_key = Sys.getenv("HETZNER_S3_SECRET_KEY_K3S")
)
)
})
# archive_package()
# grep("duckdb_", files, value = T)