fix: address fourth code review findings

- Fix FK constraint violation in SyncArtistDiscography: delete
  notifications_sent rows before external_releases to prevent
  constraint failure when re-syncing artists with prior notifications.
- Implement per-artist type filtering: FilterReleaseGroups now accepts
  FilterOptions with IgnoreSingles/IgnoreCompilations flags, read from
  artist_settings table via getArtistFilterOptions.
- Fix inconsistent error wrapping: GetExternalRelease now wraps errors
  with fmt.Errorf like all other functions in the package; updated test
  to use errors.Is for sql.ErrNoRows check.
- Add tests: FilterReleaseGroups ignore singles/compilations,
  SyncArtistDiscography per-artist type filtering, and FK-safe resync.
This commit is contained in:
2026-05-26 17:29:05 +03:00
parent 5d52a09868
commit 424be1efc4
6 changed files with 242 additions and 11 deletions

View File

@@ -9,7 +9,6 @@ import (
)
// GetExternalRelease retrieves an external_release row by RGID.
// Returns sql.ErrNoRows if the release is not found.
func GetExternalRelease(db *DB, rgid string) (*ExternalRelease, error) {
var r ExternalRelease
var cachedAt sql.NullTime
@@ -18,7 +17,7 @@ func GetExternalRelease(db *DB, rgid string) (*ExternalRelease, error) {
rgid,
).Scan(&r.RGID, &r.ArtistID, &r.Title, &r.Type, &r.ReleaseDate, &r.IsIgnored, &cachedAt)
if err != nil {
return nil, err
return nil, fmt.Errorf("get external release: %w", err)
}
if cachedAt.Valid {
r.CachedAt = cachedAt.Time