Files
metadata-agregator/internal/repository/repository.go
T
Alexander 9f1318e79e feat: fetch all artist albums with caching, filter by type in handler
- Provider fetches all release groups via paginated browse, no type filter
- Service caches all albums in DB, ensures referenced artists exist first
- Server handler filters by album_types (default: album|ep|single), excludes secondary types
- Add secondary_types to domain, DB schema, and MB types
- Add ErrBadRequest handling for MusicBrainz 400 errors
- Replace migrations with single schema.sql
- Add GetAllByArtistID and SaveAll to album repository
2026-05-07 20:03:04 +02:00

32 lines
1.3 KiB
Go

package repository
import (
"context"
"github.com/metadata-agregator/internal/domain"
)
type ArtistRepository interface {
GetByID(ctx context.Context, id string) (*domain.Artist, error)
GetByExternalID(ctx context.Context, source, sourceID string) (*domain.Artist, error)
Search(ctx context.Context, query string, limit, offset int) (*domain.SearchResult[domain.Artist], error)
Save(ctx context.Context, artist *domain.Artist) error
}
type AlbumRepository interface {
GetByID(ctx context.Context, id string) (*domain.Album, error)
GetByExternalID(ctx context.Context, source, sourceID string) (*domain.Album, error)
GetByArtistID(ctx context.Context, artistID string, limit, offset int) (*domain.SearchResult[domain.Album], error)
GetAllByArtistID(ctx context.Context, artistID string) ([]domain.Album, error)
Save(ctx context.Context, album *domain.Album) error
SaveAll(ctx context.Context, albums []domain.Album) error
}
type TrackRepository interface {
GetByID(ctx context.Context, id string) (*domain.Track, error)
GetByExternalID(ctx context.Context, source, sourceID string) (*domain.Track, error)
GetByISRC(ctx context.Context, isrc string) (*domain.Track, error)
GetByAlbumID(ctx context.Context, albumID string) ([]domain.Track, error)
Save(ctx context.Context, track *domain.Track) error
}