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

@ -417,23 +417,25 @@ func (q *Queries) GetTrackByMbzID(ctx context.Context, musicbrainzID *uuid.UUID)
return i, err
}
const getTrackByTitleAndArtists = `-- name: GetTrackByTitleAndArtists :one
const getTrackByTrackInfo = `-- name: GetTrackByTrackInfo :one
SELECT t.id, t.musicbrainz_id, t.duration, t.release_id, t.title
FROM tracks_with_title t
JOIN artist_tracks at ON at.track_id = t.id
WHERE t.title = $1
AND at.artist_id = ANY($2::int[])
AND at.artist_id = ANY($3::int[])
AND t.release_id = $2
GROUP BY t.id, t.title, t.musicbrainz_id, t.duration, t.release_id
HAVING COUNT(DISTINCT at.artist_id) = cardinality($2::int[])
HAVING COUNT(DISTINCT at.artist_id) = cardinality($3::int[])
`
type GetTrackByTitleAndArtistsParams struct {
Title string
Column2 []int32
type GetTrackByTrackInfoParams struct {
Title string
ReleaseID int32
Column3 []int32
}
func (q *Queries) GetTrackByTitleAndArtists(ctx context.Context, arg GetTrackByTitleAndArtistsParams) (TracksWithTitle, error) {
row := q.db.QueryRow(ctx, getTrackByTitleAndArtists, arg.Title, arg.Column2)
func (q *Queries) GetTrackByTrackInfo(ctx context.Context, arg GetTrackByTrackInfoParams) (TracksWithTitle, error) {
row := q.db.QueryRow(ctx, getTrackByTrackInfo, arg.Title, arg.ReleaseID, arg.Column3)
var i TracksWithTitle
err := row.Scan(
&i.ID,