fix(taste): a play still open, or closed unheard, no longer grades as a skip (#8127)

The taste build graded every play in its window, and a play with no
completion ratio and no played duration came out as completion 0: a song
playing during the rebuild, or a row the sweeper closed without hearing
how it ended, counted as abandoned and pushed its artist and tags
negative. Only plays whose completion is known are graded now; an open
play is graded once it ends.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-28 11:59:34 -05:00
co-authored by Claude Opus 5.5
parent 698ff23105
commit e2172e925e
3 changed files with 40 additions and 2 deletions
+4 -1
View File
@@ -7,7 +7,9 @@
-- completion ratio (precomputed column when present, else duration_played /
-- track duration, clamped to [0,1]); age_days drives the time-decay. Genre
-- is split into tags in Go; release_date derives the decade for the era
-- facet. Quarantined tracks are excluded.
-- facet. Quarantined tracks are excluded, and so is a play whose completion
-- isn't known: one still open (playing now), or one the sweeper closed
-- without hearing how it ended. Graded as 0 they would read as skips.
SELECT
t.id AS track_id,
t.artist_id,
@@ -23,6 +25,7 @@ JOIN tracks t ON t.id = pe.track_id
JOIN albums a ON a.id = t.album_id
WHERE pe.user_id = $1
AND pe.started_at > now() - ($2::float8 * INTERVAL '1 day')
AND (pe.completion_ratio IS NOT NULL OR pe.duration_played_ms IS NOT NULL)
AND NOT EXISTS (
SELECT 1 FROM quarantine q
WHERE q.user_id = $1 AND q.track_id = t.id