diff --git a/internal/db/dbq/candidate_artist_tags.sql.go b/internal/db/dbq/candidate_artist_tags.sql.go index 29ec71a9..a733e4a2 100644 --- a/internal/db/dbq/candidate_artist_tags.sql.go +++ b/internal/db/dbq/candidate_artist_tags.sql.go @@ -110,23 +110,17 @@ SELECT candidate_mbid, tag, weight WHERE candidate_mbid = ANY($1::text[]) ` -type ListCandidateArtistTagsForMbidsRow struct { - CandidateMbid string - Tag string - Weight float64 -} - // Cached tags for a set of candidates, for slice 6's taste-overlap ranking. // One row per (candidate, tag). -func (q *Queries) ListCandidateArtistTagsForMbids(ctx context.Context, dollar_1 []string) ([]ListCandidateArtistTagsForMbidsRow, error) { +func (q *Queries) ListCandidateArtistTagsForMbids(ctx context.Context, dollar_1 []string) ([]CandidateArtistTag, error) { rows, err := q.db.Query(ctx, listCandidateArtistTagsForMbids, dollar_1) if err != nil { return nil, err } defer rows.Close() - var items []ListCandidateArtistTagsForMbidsRow + var items []CandidateArtistTag for rows.Next() { - var i ListCandidateArtistTagsForMbidsRow + var i CandidateArtistTag if err := rows.Scan(&i.CandidateMbid, &i.Tag, &i.Weight); err != nil { return nil, err } @@ -186,10 +180,11 @@ type ListCandidateArtistsMissingTagsRow struct { // Already-in-library candidates are skipped: they have an artists row, so // their tags belong in track_tags, and the suggestion query filters them out // anyway. $1 = current tag_sources_version, $2 = limit. -// candidate_name is coalesced to '' so it lands non-nullable in Go: the name is -// only a Last.fm lookup key, and empty simply means "MBID-keyed providers only", -// which the provider chain already handles. max() is an arbitrary-but- -// deterministic pick when several seeds spell the same MBID differently. +// candidate_name is coalesced to the empty string so it lands non-nullable in +// Go: the name is only a Last.fm lookup key, and empty simply means "MBID-keyed +// providers only", which the provider chain already handles. max() is an +// arbitrary-but-deterministic pick when several seeds spell one MBID +// differently. func (q *Queries) ListCandidateArtistsMissingTags(ctx context.Context, arg ListCandidateArtistsMissingTagsParams) ([]ListCandidateArtistsMissingTagsRow, error) { rows, err := q.db.Query(ctx, listCandidateArtistsMissingTags, arg.TagSourcesVersion, arg.Limit) if err != nil { diff --git a/internal/db/dbq/models.go b/internal/db/dbq/models.go index d4ec39f7..524bb6a9 100644 --- a/internal/db/dbq/models.go +++ b/internal/db/dbq/models.go @@ -240,6 +240,12 @@ type AuditLog struct { CreatedAt pgtype.Timestamptz } +type CandidateArtistTag struct { + CandidateMbid string + Tag string + Weight float64 +} + type CandidateArtistTagState struct { CandidateMbid string TagSource string @@ -247,12 +253,6 @@ type CandidateArtistTagState struct { UpdatedAt pgtype.Timestamptz } -type CandidateArtistTag struct { - CandidateMbid string - Tag string - Weight float64 -} - type ContextualLike struct { ID pgtype.UUID UserID pgtype.UUID diff --git a/internal/db/queries/candidate_artist_tags.sql b/internal/db/queries/candidate_artist_tags.sql index 150b0637..4403689f 100644 --- a/internal/db/queries/candidate_artist_tags.sql +++ b/internal/db/queries/candidate_artist_tags.sql @@ -20,10 +20,11 @@ -- Already-in-library candidates are skipped: they have an artists row, so -- their tags belong in track_tags, and the suggestion query filters them out -- anyway. $1 = current tag_sources_version, $2 = limit. --- candidate_name is coalesced to '' so it lands non-nullable in Go: the name is --- only a Last.fm lookup key, and empty simply means "MBID-keyed providers only", --- which the provider chain already handles. max() is an arbitrary-but- --- deterministic pick when several seeds spell the same MBID differently. +-- candidate_name is coalesced to the empty string so it lands non-nullable in +-- Go: the name is only a Last.fm lookup key, and empty simply means "MBID-keyed +-- providers only", which the provider chain already handles. max() is an +-- arbitrary-but-deterministic pick when several seeds spell one MBID +-- differently. SELECT u.candidate_mbid, coalesce(max(u.candidate_name), '')::text AS candidate_name, sum(u.score)::float8 AS total_score