feat(db): add artist_similarity_unmatched schema (migration 0012)
This commit is contained in:
@@ -216,6 +216,15 @@ type ArtistSimilarity struct {
|
||||
FetchedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type ArtistSimilarityUnmatched struct {
|
||||
SeedArtistID pgtype.UUID
|
||||
CandidateMbid string
|
||||
CandidateName string
|
||||
Score float64
|
||||
Source string
|
||||
FetchedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type ContextualLike struct {
|
||||
ID pgtype.UUID
|
||||
UserID pgtype.UUID
|
||||
|
||||
@@ -172,6 +172,38 @@ func (q *Queries) UpsertArtistSimilarity(ctx context.Context, arg UpsertArtistSi
|
||||
return err
|
||||
}
|
||||
|
||||
const upsertArtistSimilarityUnmatched = `-- name: UpsertArtistSimilarityUnmatched :exec
|
||||
INSERT INTO artist_similarity_unmatched (
|
||||
seed_artist_id, candidate_mbid, candidate_name, score, source
|
||||
) VALUES ($1, $2, $3, $4, $5)
|
||||
ON CONFLICT (seed_artist_id, candidate_mbid, source) DO UPDATE SET
|
||||
candidate_name = EXCLUDED.candidate_name,
|
||||
score = EXCLUDED.score,
|
||||
fetched_at = now()
|
||||
`
|
||||
|
||||
type UpsertArtistSimilarityUnmatchedParams struct {
|
||||
SeedArtistID pgtype.UUID
|
||||
CandidateMbid string
|
||||
CandidateName string
|
||||
Score float64
|
||||
Source string
|
||||
}
|
||||
|
||||
// Persists an out-of-library similar-artist MBID. Idempotent on
|
||||
// (seed_artist_id, candidate_mbid, source) — re-fetches refresh the
|
||||
// name/score and bump fetched_at.
|
||||
func (q *Queries) UpsertArtistSimilarityUnmatched(ctx context.Context, arg UpsertArtistSimilarityUnmatchedParams) error {
|
||||
_, err := q.db.Exec(ctx, upsertArtistSimilarityUnmatched,
|
||||
arg.SeedArtistID,
|
||||
arg.CandidateMbid,
|
||||
arg.CandidateName,
|
||||
arg.Score,
|
||||
arg.Source,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
const upsertTrackSimilarity = `-- name: UpsertTrackSimilarity :exec
|
||||
INSERT INTO track_similarity (track_a_id, track_b_id, score, source, fetched_at)
|
||||
VALUES ($1, $2, $3, 'listenbrainz', now())
|
||||
|
||||
Reference in New Issue
Block a user