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:
@@ -175,11 +175,10 @@ func GetExternalReleasesByArtistWithCache(db *DB, artistID string, ttl time.Dura
|
||||
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.
|
||||
const layout = "2006-01-02 15:04:05"
|
||||
cutoff := time.Now().UTC().Add(-ttl).Format(layout)
|
||||
// cached_at is stored in utcLayout via FormatCachedAt. Compare against an
|
||||
// explicitly formatted cutoff string in the same layout so the
|
||||
// lexicographic comparison is a valid time ordering.
|
||||
cutoff := time.Now().UTC().Add(-ttl).Format(utcLayout)
|
||||
rows, err := db.Conn().Query(
|
||||
"SELECT rgid, artist_id, title, type, release_date, is_ignored, cached_at, secondary_types FROM external_releases WHERE artist_id = ? AND cached_at >= ?",
|
||||
artistID, cutoff,
|
||||
|
||||
Reference in New Issue
Block a user