fix: set first artist listed as primary by default (#81)

This commit is contained in:
Gabe Farrell 2025-10-24 17:52:07 -04:00 committed by GitHub
parent cd31b6f2d8
commit 70f5198781
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 46 additions and 26 deletions

View file

@ -144,6 +144,7 @@ func (d *Psql) SaveAlbum(ctx context.Context, opts db.SaveAlbumOpts) (*models.Al
err = qtx.AssociateArtistToRelease(ctx, repository.AssociateArtistToReleaseParams{
ArtistID: artistId,
ReleaseID: r.ID,
IsPrimary: opts.ArtistIDs[0] == artistId,
})
if err != nil {
return nil, fmt.Errorf("SaveAlbum: AssociateArtistToRelease: %w", err)

View file

@ -132,8 +132,9 @@ func (d *Psql) SaveTrack(ctx context.Context, opts db.SaveTrackOpts) (*models.Tr
// insert associated artists
for _, aid := range opts.ArtistIDs {
err = qtx.AssociateArtistToTrack(ctx, repository.AssociateArtistToTrackParams{
ArtistID: aid,
TrackID: trackRow.ID,
ArtistID: aid,
TrackID: trackRow.ID,
IsPrimary: opts.ArtistIDs[0] == aid,
})
if err != nil {
return nil, fmt.Errorf("SaveTrack: AssociateArtistToTrack: %w", err)