Promote test → main: measurements + measurement-jobs (chat#1796)
Merged
SW
4mo ago+1613+1613+0123456789012345678901234567890123456789-8-8-0123456789
Promote the two merged chat#1796 PRs from test to main (prod).
Includes:
- #668 —
measurement-jobswrite resource (POST /research/measurement-jobs,source: current|historical) + card-on-file gate onhistorical+ retryable backfill drain / reclaim. - #669 —
measurementsread collection (GET /research/tracks|albums/{id}/measurements, series +aggregate=run_rate+latest).
Both verified on preview (results in the respective PRs). Additive — legacy endpoints keep serving. After this lands, the catalog-value-estimator seed (skills#43) works against prod.
Summary by cubic
Promotes consolidated research measurement APIs to prod: adds POST /api/research/measurement-jobs for ingest and GET /api/research/tracks|albums/{id}/measurements for reads. Also adds a Songstats card-on-file gate and makes the historical backfill drain retryable with automatic reclaim in maintenance. Legacy endpoints remain available.
-
New Features
POST /api/research/measurement-jobs—{ scope, source }:source: "current"uses the snapshot pipeline (mapssnapshot_id→id).source: "historical"enqueues Songstats backfill ranked by latest counts; skips songs already backfilled; bounded concurrency; returns 202.- Validation: auth + research credits;
historicalrequires a payment method;currentdoes not.
GET /api/research/tracks/{id}/measurements— daily series;?aggregate=run_rateover a trailing window.{id}can be ISRC or a Spotify track id (resolved to ISRC).GET /api/research/albums/{id}/measurements— latest count per track (thin remap of playcounts). CORS preflight added for new routes.
-
Reliability
- Backfill drain: 408/429/5xx are marked
failed(reclaimable); 404 and other permanent 4xx are markeddone(terminal). - Maintenance cron reclaims
failedand stalein_progressrows before draining and reports the reclaimed count.
- Backfill drain: 408/429/5xx are marked
Summary by CodeRabbit
-
New Features
- Added research measurement endpoints for retrieving album and track playcount data
- Introduced measurement job creation supporting historical backfills and current snapshots
- Added measurement aggregation options, including run-rate projections
- Implemented payment method validation for measurement features
-
Improvements
- Enhanced error handling with better categorization for failed requests
- Improved queue management with staleness detection and recovery mechanisms