Files
NaviWatcher/internal/musicbrainz/cache.go
Vladimir Zagainov 582202bb86 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).
2026-05-26 15:58:40 +03:00

20 lines
586 B
Go

package musicbrainz
import (
"fmt"
"time"
"naviwatcher/internal/database"
)
// GetCachedReleases queries the external_releases table for entries
// belonging to the given artist that were cached within the specified TTL.
// 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 nil, fmt.Errorf("get cached releases: %w", err)
}
return releases, nil
}