fix: track durations showing 0:00 — stop merging index recordings
Index recordings lack duration data (Length=0) because the explore index only stores title/artist/popularity. When mergeIndexHits prepended 15+ index recordings, they filled the maxResults cap and pushed the MB recordings (which have real durations) off the list. Removed recording merging from mergeIndexHits entirely. Index artists and release groups are still merged (they carry popularity data the MB results lack), but recordings don't benefit from index merging — MB search already returns them with proper metadata.
This commit is contained in:
@@ -740,18 +740,11 @@ func mergeIndexHits(result *MBSearchResult, hits []SearchIndexResult) {
|
||||
rgMBIDs[rg.MBID] = true
|
||||
}
|
||||
|
||||
recMBIDs := make(map[string]bool, len(result.Recordings))
|
||||
for _, r := range result.Recordings {
|
||||
recMBIDs[r.MBID] = true
|
||||
}
|
||||
|
||||
// Collect new entries from index.
|
||||
var newArtists []MBArtist
|
||||
|
||||
var newRGs []MBReleaseGroup
|
||||
|
||||
var newRecs []MBRecording
|
||||
|
||||
for _, h := range hits {
|
||||
switch h.EntityType {
|
||||
case "artist":
|
||||
@@ -787,16 +780,11 @@ func mergeIndexHits(result *MBSearchResult, hits []SearchIndexResult) {
|
||||
}
|
||||
|
||||
case "recording":
|
||||
if !recMBIDs[h.MBID] {
|
||||
newRecs = append(newRecs, MBRecording{
|
||||
MBID: h.MBID,
|
||||
Title: h.Title,
|
||||
ArtistCredit: h.ArtistName,
|
||||
Score: scalePopularity(h.Popularity),
|
||||
})
|
||||
|
||||
recMBIDs[h.MBID] = true
|
||||
}
|
||||
// Skip index recordings — they lack duration data and
|
||||
// don't add value over MB search results which have it.
|
||||
// Index artists and release groups are still merged
|
||||
// because they carry popularity data the MB results lack.
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
@@ -808,10 +796,6 @@ func mergeIndexHits(result *MBSearchResult, hits []SearchIndexResult) {
|
||||
if len(newRGs) > 0 {
|
||||
result.ReleaseGroups = append(newRGs, result.ReleaseGroups...)
|
||||
}
|
||||
|
||||
if len(newRecs) > 0 {
|
||||
result.Recordings = append(newRecs, result.Recordings...)
|
||||
}
|
||||
}
|
||||
|
||||
// scalePopularity maps a raw LB listen count to a 0–100 score
|
||||
|
||||
Reference in New Issue
Block a user