ML-170: add enrichment fields to collection API

Add MusicLibrary.Collection.Enrichment module with batch scrobble, artist
country, and selected release enrichment from existing tables.

Wire enrichment into all four collection API endpoints (index, latest,
random, on_this_day). New JSON fields: scrobble_count, last_listened_at,
artist_country, selected_release.

Uses 3 fixed-count batch queries regardless of page size — no N+1 risk.
No schema changes or migrations required.
This commit is contained in:
Claudio Ortolina
2026-05-22 13:18:56 +01:00
parent c41299f6c1
commit ff3f809c2c
7 changed files with 643 additions and 50 deletions
@@ -327,6 +327,17 @@ defmodule MusicLibraryWeb.CollectionControllerTest do
"large" => asset_url(record.cover_hash, 1000),
"medium" => asset_url(record.cover_hash, 400),
"small" => asset_url(record.cover_hash, 80)
},
"scrobble_count" => 0,
"last_listened_at" => nil,
"artist_country" => nil,
"selected_release" => %{
"catalog_number" => "",
"country" => "GB",
"date" => "2004-05-03",
"disambiguation" => "",
"format" => "multi",
"packaging" => "Jewel Case"
}
}
end