release / go (push) Successful in 1m49s
release / web (push) Successful in 1m16s
release / govulncheck (push) Successful in 25s
release / integration (push) Failing after 4m12s
release / android (push) Successful in 4m47s
release / Build signed APK (push) Successful in 5m24s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Skipped
release / Verify release artifacts (tag releases only) (push) Skipped
A like is on the song: LikeTrack and UnlikeTrack change every copy sharing its song_key. The contextual like (the session captured while it played) is written on the copy that was playing, but an unlike soft-deleted only the copy it named. Unliking from the Liked list, which shows one copy per song, or from another album holding the song, left the context active, and the engine kept boosting candidates matching it. The soft-delete now covers every copy of the song, and the engine's reader counts only contexts whose song is still liked, as a backstop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
101 lines
3.1 KiB
Go
101 lines
3.1 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
// source: contextual_likes.sql
|
|
|
|
package dbq
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const insertContextualLike = `-- name: InsertContextualLike :exec
|
|
INSERT INTO contextual_likes (user_id, track_id, session_vector, session_id)
|
|
VALUES ($1, $2, $3, $4)
|
|
`
|
|
|
|
type InsertContextualLikeParams struct {
|
|
UserID pgtype.UUID
|
|
TrackID pgtype.UUID
|
|
SessionVector []byte
|
|
SessionID pgtype.UUID
|
|
}
|
|
|
|
func (q *Queries) InsertContextualLike(ctx context.Context, arg InsertContextualLikeParams) error {
|
|
_, err := q.db.Exec(ctx, insertContextualLike,
|
|
arg.UserID,
|
|
arg.TrackID,
|
|
arg.SessionVector,
|
|
arg.SessionID,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const listActiveContextualLikesForUser = `-- name: ListActiveContextualLikesForUser :many
|
|
SELECT cl.track_id, cl.session_vector
|
|
FROM contextual_likes cl
|
|
WHERE cl.user_id = $1
|
|
AND cl.deleted_at IS NULL
|
|
AND cl.session_vector IS NOT NULL
|
|
AND EXISTS (SELECT 1 FROM general_likes g WHERE g.user_id = cl.user_id AND g.track_id = cl.track_id)
|
|
`
|
|
|
|
type ListActiveContextualLikesForUserRow struct {
|
|
TrackID pgtype.UUID
|
|
SessionVector []byte
|
|
}
|
|
|
|
// Returns all the user's active (non-soft-deleted) contextual_likes with
|
|
// non-null vectors. Cardinality is bounded by the user's actual like-while-
|
|
// playing history — typically tens to low hundreds. Used by the engine to
|
|
// compute contextual_match_score for the candidate pool.
|
|
//
|
|
// Only rows whose song is still liked count, so a context left active by
|
|
// an unlike that missed it can't keep boosting a song the user let go of.
|
|
func (q *Queries) ListActiveContextualLikesForUser(ctx context.Context, userID pgtype.UUID) ([]ListActiveContextualLikesForUserRow, error) {
|
|
rows, err := q.db.Query(ctx, listActiveContextualLikesForUser, userID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []ListActiveContextualLikesForUserRow
|
|
for rows.Next() {
|
|
var i ListActiveContextualLikesForUserRow
|
|
if err := rows.Scan(&i.TrackID, &i.SessionVector); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const softDeleteContextualLikesForUserTrack = `-- name: SoftDeleteContextualLikesForUserTrack :exec
|
|
UPDATE contextual_likes
|
|
SET deleted_at = now()
|
|
WHERE user_id = $1::uuid
|
|
AND deleted_at IS NULL
|
|
AND (track_id = $2::uuid
|
|
OR track_id IN (SELECT t.id FROM tracks t
|
|
WHERE t.song_key = (SELECT s.song_key FROM tracks s WHERE s.id = $2::uuid)))
|
|
`
|
|
|
|
type SoftDeleteContextualLikesForUserTrackParams struct {
|
|
UserID pgtype.UUID
|
|
TrackID pgtype.UUID
|
|
}
|
|
|
|
// Marks the user's active rows for the song as deleted: every copy sharing
|
|
// the track's song_key, as UnlikeTrack removes the like from every copy.
|
|
// The context was captured on whichever copy was playing, which needn't be
|
|
// the one the unlike names. Idempotent — already-deleted rows aren't
|
|
// re-touched.
|
|
func (q *Queries) SoftDeleteContextualLikesForUserTrack(ctx context.Context, arg SoftDeleteContextualLikesForUserTrackParams) error {
|
|
_, err := q.db.Exec(ctx, softDeleteContextualLikesForUserTrack, arg.UserID, arg.TrackID)
|
|
return err
|
|
}
|