fix: associate tracks with release when scrobbling (#118)

This commit is contained in:
Gabe Farrell 2026-01-01 02:40:27 -05:00 committed by GitHub
parent d327729bff
commit c346c7cb31
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 58 additions and 1794 deletions

View file

@ -52,14 +52,15 @@ func (d *Psql) GetTrack(ctx context.Context, opts db.GetTrackOpts) (*models.Trac
AlbumID: t.ReleaseID,
Duration: t.Duration,
}
} else if len(opts.ArtistIDs) > 0 {
l.Debug().Msgf("Fetching track from DB with title '%s' and artist id(s) '%v'", opts.Title, opts.ArtistIDs)
t, err := d.q.GetTrackByTitleAndArtists(ctx, repository.GetTrackByTitleAndArtistsParams{
Title: opts.Title,
Column2: opts.ArtistIDs,
} else if len(opts.ArtistIDs) > 0 && opts.ReleaseID != 0 {
l.Debug().Msgf("Fetching track from DB from release id %d with title '%s' and artist id(s) '%v'", opts.ReleaseID, opts.Title, opts.ArtistIDs)
t, err := d.q.GetTrackByTrackInfo(ctx, repository.GetTrackByTrackInfoParams{
Title: opts.Title,
ReleaseID: opts.ReleaseID,
Column3: opts.ArtistIDs,
})
if err != nil {
return nil, fmt.Errorf("GetTrack: GetTrackByTitleAndArtists: %w", err)
return nil, fmt.Errorf("GetTrack: GetTrackByTrackInfo: %w", err)
}
track = models.Track{
ID: t.ID,