release: Apify-first Spotify play counts (test โ†’ main)

Merged
SW
4mo ago
+1357-390

Promotes exactly one change: #657 โ€” GET /api/research/track/stats serves Spotify from the song_measurements store (24h TTL, whole-album actor refresh, Songstats fallback, data_source provenance per docs#238).

Verified twice on previews (results tables on #657), including live actor run + store-fresh repeat read. Release scope checked: 8b209dad is the only commit on test not on main.

Part of recoupable/chat#1791.

๐Ÿค– Generated with Claude Code


Summary by cubic

Serve Spotify play counts in GET /api/research/track/stats from the song_measurements store with a 24h TTL, refreshing via the beatanalytics~spotify-play-count-scraper actor per album and writing sibling tracks. Falls back to Songstats when the store can't answer and adds data_source to every stat.

  • New Features
    • For spotify + isrc: serve fresh store data; if stale, refresh album via actor and degrade to the stale value on actor failure.
    • Whole-album refresh writes all mapped tracks, with raw_ref set to the actor run id.
    • Non-Spotify or non-ISRC requests use Songstats; mixed-source queries merge store-backed Spotify with Songstats stats, labeling Songstats entries.
    • Charge 5 credits when the response is store-only; TTL is configurable via SPOTIFY_PLAYCOUNT_TTL_HOURS (default 24h).

Summary by CodeRabbit

Release Notes

  • New Features
    • Integrated Apify-based Spotify playcount fetching with smart measurement caching and freshness detection
    • Implemented credit deduction system for research API requests
    • Added data source attribution to track statistics results for improved transparency