feat(feed): suppress recently-played tracks in for-you feed#950
Merged
Conversation
Tracks the user played in the last 14 days now get a repeat_penalty multiplier on final_score (0.25x if played in the last 7 days, 0.5x in the last 8-14 days, 1.0x otherwise) so the feed surfaces fresh content. Suppressed tracks stay in the feed, just ranked lower. Playlists are unaffected (no per-user playlist play data). The play-history scan is bounded the same way as the affinity sub-select (most recent 2000 rows before the 14-day window) so heavy listeners can't pull the CTE wide. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
dylanjeffers
added a commit
that referenced
this pull request
Jun 12, 2026
Item 3 of the for-you feed improvement queue (follows #949 content-type weighting and #950 repeat suppression). ## What Adds a **genre_affinity** multiplier to final_score, built from the genre mix of the viewer's recent listening: - New \`my_genre_affinity\` CTE: joins the viewer's most recent plays (bounded to the last 1000, same pattern as the other play sub-selects) to \`tracks.genre\` and computes each genre's share of plays. - Multiplier: \`0.85 + 0.45 * min(genre_share / 0.30, 1)\` — a genre at >=30% of recent listening gets the full **1.30x**, genres the viewer never plays get **0.85x**. - Neutral 1.00x for playlists (no single genre), genre-less tracks, and cold-start users with no play history (no penalty when we know nothing). ## Tests - \`TestV1FeedForYou_GenreAffinityBoostsFavoredGenre\`: an all-Electronic listener sees the Electronic sibling outrank the naturally-stronger Rock sibling, while the Rock track stays in the feed. - \`TestV1FeedForYou_GenreAffinityNeutralOnColdStart\`: no play history → natural ranking unchanged. \`go build ./...\` and the full \`go test ./...\` suite pass locally. 🤖 Opened by the automated feed-algorithm-improvement-loop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds repeat suppression to the For You feed: tracks the user has already played recently are scored lower so fresh content surfaces first.
How
my_recent_playsCTE pulls the user's play history from theplaystable, bounded to the most recent 2000 rows (same pattern as the affinity sub-select, per the performance notes from perf(for-you): cap my_saved_artists to 200 most-recent #805/perf(for-you): bound my_artist_affinity and follow_set by recency #806) before applying a 14-day window, keepingMAX(created_at)per track.repeat_penaltymultiplier in the scoring CTE:repeat_penaltymultipliesfinal_scorealongside the existingsocial_boost,source_weight, andcontent_type_weight.Tests
TestV1FeedForYou_RepeatSuppressionDownranksPlayedTracks— a 2-day-old play pushes a track below an otherwise lower-scored sibling, while keeping it in the feed.TestV1FeedForYou_OldPlaysDoNotSuppress— a 20-day-old play is outside the window and does not downrank.🤖 Generated with Claude Code