fix: address code review findings

This commit is contained in:
2026-07-19 20:53:06 +03:00
parent da8b8aa944
commit 2468859435
9 changed files with 34 additions and 228 deletions

View File

@@ -169,6 +169,12 @@ func SetReleaseIgnored(db *DB, rgid string, ignored bool) error {
// GetExternalReleasesByArtistWithCache returns cached external_release rows for a given artist_id
// that are within the specified TTL.
func GetExternalReleasesByArtistWithCache(db *DB, artistID string, ttl time.Duration) ([]ExternalRelease, error) {
// A zero or negative TTL means "no cache" — always expire. Returning early
// here avoids the boundary pitfall where cutoff == now would treat rows
// cached in the current second as fresh.
if ttl <= 0 {
return nil, nil
}
// cached_at is stored in the "2006-01-02 15:04:05" UTC layout via
// FormatCachedAt. Compare against an explicitly formatted cutoff string in
// the same layout so the lexicographic comparison is a valid time ordering.