fix: address code review findings
- Fix pagination to not trust MusicBrainz count for cutoff (prevents silent discography truncation / hidden missing releases) - Add idx_external_releases_artist_id index for hot per-artist queries - Dedupe cached_at layout constant in external_releases.go
This commit is contained in:
@@ -46,10 +46,14 @@ func (c *MusicBrainzClient) GetArtistReleaseGroups(ctx context.Context, artistMB
|
||||
|
||||
allGroups = append(allGroups, parsed.ReleaseGroups...)
|
||||
|
||||
// If we've fetched all results, we've reached the end.
|
||||
// Also break on empty page to prevent infinite loop if API
|
||||
// returns fewer items than advertised by count.
|
||||
if len(parsed.ReleaseGroups) == 0 || offset+len(parsed.ReleaseGroups) >= parsed.Count {
|
||||
// Stop when a page is empty (no more results) or when the page
|
||||
// returned fewer items than the request limit — a reliable end-of-data
|
||||
// signal. We intentionally do NOT trust parsed.Count for the cutoff:
|
||||
// MusicBrainz occasionally reports an inaccurate count, which would
|
||||
// prematurely truncate an artist's discography and hide missing
|
||||
// releases. The empty-page check also prevents an infinite loop if the
|
||||
// API keeps returning a non-empty page past the reported count.
|
||||
if len(parsed.ReleaseGroups) == 0 || len(parsed.ReleaseGroups) < limit {
|
||||
break
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user