fix: address second code review findings
- Add context cancellation check between pagination pages in GetArtistReleaseGroups for responsive graceful shutdown during large discography fetches. - Eliminate double DB query on cache hit by having GetCachedReleases return []ExternalRelease directly instead of just a count, avoiding a redundant second query in SyncArtistDiscography. - Update cache_test.go to match new GetCachedReleases return type. - Format main.go (pre-existing whitespace issue).
This commit is contained in:
@@ -9,11 +9,11 @@ import (
|
||||
|
||||
// GetCachedReleases queries the external_releases table for entries
|
||||
// belonging to the given artist that were cached within the specified TTL.
|
||||
// It returns the count of cached entries and any error encountered.
|
||||
func GetCachedReleases(db *database.DB, artistID string, ttl time.Duration) (int, error) {
|
||||
// It returns the cached releases and any error encountered.
|
||||
func GetCachedReleases(db *database.DB, artistID string, ttl time.Duration) ([]database.ExternalRelease, error) {
|
||||
releases, err := database.GetExternalReleasesByArtistWithCache(db, artistID, ttl)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("get cached releases: %w", err)
|
||||
return nil, fmt.Errorf("get cached releases: %w", err)
|
||||
}
|
||||
return len(releases), nil
|
||||
return releases, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user