release: self-mapping album captures (test → main)

Merged
SW
4mo ago
+376-4

Promotes the chat#1794 fix: #664 — self-mapping album captures (Spotify ISRC resolution for unmapped tracks) + album rows for every captured track, paired with the merged database#34 constraint fix.

Content delta vs main is exactly the #664 squash (older commits listed in the range are squash-promotion artifacts; trees were identical before the fix). Live-verified on preview: K.I.D.S. + REBIRTH both 18/18 in /playcounts, sibling stats store-served, credit accounting exact (results tables on #664).

šŸ¤– Generated with Claude Code


Summary by cubic

Album captures now self-map unmapped Spotify track IDs to ISRCs and write measurements for all resolved tracks, also upserting album_id mappings per captured track. This fixes skipped tracks in playcount captures and heals pre-mapped tracks missing album rows.

  • Bug Fixes
    • Resolve ISRCs for unmapped tracks via Spotify GET /v1/tracks (batched at 50); added getTracks.
    • Upsert songs and song_identifiers (track_id and album_id) with new upsertSongIdentifiers (idempotent; aligned with the per-song uniqueness constraint).
    • writeAlbumPlayCounts now self-maps before writing and always upserts an album_id row for each captured track; degrades gracefully if Spotify auth fails.
    • Tests added for mapping, write path, and identifier upserts; SpotifyAlbumPlayCounts type now includes optional id for album context.