Enhance mapSongstatsArtistPath to utilize new queries for artist albums and top tracks.

AH
6mo ago
+659-8

Update tests to verify correct mapping of artist albums and tracks to respective endpoints, ensuring proper data retrieval and normalization.


Summary by cubic

Switch artist albums and tracks to SongStats’ dedicated endpoints with safer defaults, cleaner filtering, and safe query passthrough. Albums default to primary-only; tracks use top tracks with a primary-catalog fallback.

  • New Features

    • Map /artist/:id/albums to /artists/catalog via buildArtistCatalogQuery; default is_primary=true (accepts is_primary/isPrimary, empty treated as true), respect limit/offset, normalize items with id.
    • Map /artist/:id/tracks to /artists/top_tracks via buildArtistTopTracksQuery; default source=spotify, metric=popularity, flatten and filter noise; fall back to a filtered primary catalog slice via fetchArtistTracksFromSongstats (default limit 50).
    • Forward limit, offset, source, and metric to tracks through getResearchTracksHandler.
  • Refactors

    • Use resolveCatalogPrimary and appendPassthroughQueryParams; block artist ID overrides; update mapSongstatsArtistPath to call new helpers; simplify buildArtistTopTracksQuery by removing unused params.
    • Improve normalization: normalizeArtistAlbums drops non-object rows and filters noisy/secondary items when primary-only; shouldIncludeCatalogItem excludes entries without a title/track ID, remix/feature flags, or secondary roles with clearer inclusion logic.

Summary by CodeRabbit

Release Notes

  • New Features
    • Enhanced artist discography browsing with improved album and track catalog retrieval.
    • Added filtering capabilities to exclude noisy or secondary catalog entries (remixes, features, non-primary releases).
    • Implemented primary vs. non-primary release filtering for more relevant artist results.