feat: implement MusicBrainz sync orchestration with caching and upsert
Creates internal/musicbrainz/sync.go with SyncArtistDiscography function that orchestrates the full flow: cache check via GetCachedReleases, fetch from MusicBrainz API on cache miss, filter via FilterReleaseGroups, and upsert into external_releases via database.SaveExternalRelease. Includes SyncArtistDiscographyWithFilter variant for per-artist type filtering. All functions support context cancellation. 14 new tests cover cache hit/miss, status/type filtering, context cancellation, idempotency, API errors, and full XML pipeline integration.
This commit is contained in:
@@ -75,13 +75,13 @@ Implement a MusicBrainz API provider with strict 1 request/second rate limiting,
|
||||
- [x] run tests - must pass before next task
|
||||
|
||||
### Task 4: Implement database integration and sync orchestration
|
||||
- [ ] create `internal/musicbrainz/sync.go` with SyncArtistDiscography function
|
||||
- [ ] implement upsert logic: INSERT OR REPLACE into external_releases table
|
||||
- [ ] add cached_at column to external_releases table via migration
|
||||
- [ ] implement context.Context support for cancellation
|
||||
- [ ] write tests for database upsert operations
|
||||
- [ ] write integration tests with in-memory SQLite
|
||||
- [ ] run tests - must pass before next task
|
||||
- [x] create `internal/musicbrainz/sync.go` with SyncArtistDiscography function
|
||||
- [x] implement upsert logic: INSERT OR REPLACE into external_releases table
|
||||
- [x] add cached_at column to external_releases table via migration (done in Task 3 as migration 005)
|
||||
- [x] implement context.Context support for cancellation
|
||||
- [x] write tests for database upsert operations
|
||||
- [x] write integration tests with in-memory SQLite
|
||||
- [x] run tests - must pass before next task
|
||||
|
||||
### Task 5: Wire up provider in application entry point
|
||||
- [ ] update `cmd/naviwatcher/main.go` to initialize MusicBrainz client
|
||||
|
||||
Reference in New Issue
Block a user