[Feed] Add GET /v1/users/{id}/feed/for-you endpoint#797
Open
dylanjeffers wants to merge 3 commits intomainfrom
Open
[Feed] Add GET /v1/users/{id}/feed/for-you endpoint#797dylanjeffers wants to merge 3 commits intomainfrom
dylanjeffers wants to merge 3 commits intomainfrom
Conversation
…lgorithm Implements a personalized For You feed modeled on Twitter's 2023 open-sourced timeline pipeline (candidate generation -> ranking -> filtering -> diversity). Candidate sources (4): - in-network: recent uploads from artists the viewer follows - weekly trending (track_trending_scores, time_range=week) - underground trending (sub-1500 follower/following artists) - similar-artist 1-hop CF: artists co-saved by users who saved my saved artists' tracks Ranking (SQL-side): - 48h half-life recency: EXP(-LN(2) * hours_old / 48) - engagement: LN(1 + 3*saves + 2*reposts + plays) (saves > reposts > plays) - social affinity: 1 + min(LN(1 + my_engagement_count) / 4, 1) - source weight: in-network 1.20, trending 1.00, underground 0.95, similar 0.90 Filtering / diversity: - hard filters mirror the v1_events_remix_contests.go pattern: is_delete=false, is_unlisted=false, is_available=true, stem_of IS NULL, no access_authorities, owner not deactivated - excludes tracks the viewer has already saved - 3-per-artist cap via ROW_NUMBER() OVER (PARTITION BY owner_id) - Go-side greedy diversity pass with a 5-track lookahead to avoid consecutive same-artist tracks without disturbing global rank Pagination: user_id (required), limit (1-100, default 25), offset (0-200). Consumed by apps#14237. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add the OpenAPI entry for the new endpoint so it shows up in /v1 (swagger UI) and the SDK codegen pipeline. Documents the four query params (user_id required; limit, offset, max_per_artist optional with min/max bounds matching the handler's validate tags) and points the 200 response at the existing "tracks" component schema. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Server-side replacement for the client-side blend in apps' useForYouFeed.ts. Four candidate streams interleaved with a fixed 10-slot pattern, pos: [R R R F R T R F U R] giving 60% recommended (50% baseline + 10% filler when other sources thin out), 20% following originals, 10% trending, 10% underground. When a slot's preferred source is exhausted, falls through in priority order recommended → following → trending → underground. Each source caps at 200 candidates; the union is deduped by track_id and the caller's already-saved tracks are filtered at the SQL level (client filtered them client-side; filtering early avoids burning candidates on already-saved tracks). Pagination (limit/offset) applies to the composed list. Source SQL mirrors the underlying single-source endpoints: - recommended: v1_users_recommended_tracks.go (top tracks from the user's top-played genres, excluding played) — switched to score-DESC ordering for stable pagination - following: v1_users_feed.go w/ filter=original - trending: v1_tracks_trending.go (week) - underground: v1_tracks_trending_underground.go (week, sub-1500 follower & following artists) Liveness, gating, and unlisted/deleted filters mirror those files and v1_events_remix_contests.go. Path-param userId (the requesting user) follows the same pattern as /v1/users/:userId/recommended-tracks and /v1/users/:userId/feed. Consumed by apps' useForYouFeed.ts. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Server-side replacement for the client-side blend in
apps/packages/common/src/api/tan-query/lineups/useForYouFeed.ts. AddsGET /v1/users/{id}/feed/for-you— a user-scoped For You feed that mirrors the apps' four-source blend on the server.[R R R F R T R F U R]→ 60% recommended / 20% following / 10% trending / 10% underground. Falls through in priority order when a source is exhausted.track_id. Already-saved tracks are excluded at the SQL level rather than re-emitting them as "new" recommendations.v1_users_recommended_tracks.go,v1_users_feed.gofilter=original,v1_tracks_trending.go,v1_tracks_trending_underground.go); recommended switched to score-DESC ordering for stable pagination. Liveness/gating/unlisted/deleted filters match those files andv1_events_remix_contests.go.limit/offsetpagination applied to the composed list.Path-param
:userIdis the requesting user (same auth pattern as/v1/users/:userId/recommended-tracksand/v1/users/:userId/feed).Consumed by apps'
useForYouFeed.ts.Test plan
blendForYouSourcesproduces canonical[R R R F R T R F U R]ordering when every source is full400when:userIdis not a valid hash idlimit/offsetpagination doesn't repeat400for invalidlimit/offset(negative, over max, non-numeric)go build ./api/...,go vet ./api/...cleanTestV1FeedForYou*,TestV1UsersFeed*,TestV1UserTracks*,TestV1UsersRecommendedTracks*,Test200*still pass🤖 Generated with Claude Code