refactor(for-you): back feed's For You tab with /recommended-tracks#14301
Merged
Conversation
The Feed page's For You tab previously hit a dedicated
`/v1/users/{id}/feed/for-you` endpoint with its own custom server-side
ranker. That endpoint had auth and perf problems and was producing the
same kind of content as the Explore page's existing For You section —
which is already powered by `/v1/users/{id}/recommended-tracks`.
Consolidate: rewrite `useForYouFeed`'s queryFn to call
`sdk.users.getUserRecommendedTracks`, the same method the Explore
section uses (see `useRecommendedTracks`, `ForYouTracks.tsx`,
`RecommendedTracksSection.tsx`). The hook's public shape is unchanged —
exports, return fields, and page-size constants stay identical — so
the three consumers (`FeedPageContent` desktop + mobile, mobile
`FeedScreen`) need no changes.
The `/feed/for-you` endpoint is being deleted from the API in a
companion PR.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
dylanjeffers
added a commit
to AudiusProject/api
that referenced
this pull request
May 13, 2026
## Summary
Retiring the dedicated For You feed endpoint. The clients are being
switched to use \`/v1/users/{id}/recommended-tracks\` instead — the same
endpoint that already powers the Explore page's For You section and
works fine in production. See companion PR: AudiusProject/apps#14301.
## Why
The custom \`/feed/for-you\` endpoint had repeated issues since it
shipped:
* **Auth gate bug** (fixed in #804) — global authMiddleware rejected
unsigned \`user_id\` requests, making the endpoint unreachable from the
web RC.
* **Perf** — even after #805 and #806 capped the \`my_saved_artists\`,
\`my_artist_affinity\`, and \`follow_set\` CTEs, EXPLAIN on prod showed
the \`similar_artists\` self-join still produced a 301M-row merge for
power users (and a fixed ~12s \`track_trending_scores\` scan for *every*
user due to a missing partial index). The endpoint never reliably
completed within Cloudflare's 100s upstream limit for power users.
* **Duplication** — the response shape (ranked track list for the
signed-in user) is already what \`/recommended-tracks\` returns. Two
endpoints solving the same problem isn't worth maintaining.
Consolidating on the working endpoint is simpler than continuing to
optimize the custom one.
## Removed
| File | What |
|---|---|
| \`api/v1_users_feed_for_you.go\` | Handler + the 200-row
candidate-pool SQL (4 candidate sources, similar_artists CF, diversity
pass) |
| \`api/v1_users_feed_for_you_test.go\` | 9 unit tests |
| \`api/server.go\` (1 line) | Route registration |
| \`api/auth_middleware.go\` (~10 lines) | The \`/feed/for-you\`
exemption from #804 — no longer needed |
| \`api/swagger/swagger-v1.yaml\` (~70 lines) | The endpoint's swagger
entry |
## Test plan
- ✅ \`go build ./api/...\` clean
- ✅ \`go vet ./api/...\` clean
- ✅ All remaining \`TestV1UsersFeed*\` / \`TestAuth*\` tests pass
locally
- After merge + deploy + AudiusProject/apps#14301 deploy: Feed → For You
tab on the web RC should show the same recommended tracks as Explore's
For You section.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
🌐 Web preview readyPreview URL: https://audius-web-preview-pr-14301.audius.workers.dev Unique preview for this PR (deployed from this branch). |
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
The Feed page's For You tab hit a dedicated
/v1/users/{id}/feed/for-youendpoint with its own custom server-side ranker. That endpoint had:similar_artistsself-join still timed out — see [EXPLAIN ANALYZE writeup])Meanwhile, the Explore page's For You section already exists, works fine, and is powered by
/v1/users/{id}/recommended-tracks(viauseRecommendedTracks→sdk.users.getUserRecommendedTracks). Same shape: ranked track list for the signed-in user.This PR consolidates: rewrite
useForYouFeed's queryFn to call the same SDK method the Explore section uses. The custom/feed/for-youendpoint is being deleted from the API in a companion PR.What changed
packages/common/src/api/tan-query/lineups/useForYouFeed.tssdk.users.getUserForYouFeed(...)→sdk.users.getUserRecommendedTracks(... timeRange: Week)What stayed the same (intentionally — so consumers don't touch)
useForYouFeed,FOR_YOU_INITIAL_PAGE_SIZE,FOR_YOU_LOAD_MORE_PAGE_SIZE,getForYouFeedQueryKeytrackIds,isPending,isLoading,isFetching,isSuccess,isError,isInitialLoading,hasNextPage,fetchNextPage,loadNextPage,refetch,queryKey)isDisabledempty-state behavior added in fix: render For You empty state when feed query is disabled #14290/fix: stop For You feed skeletons when query is disabled #14291Verified consumers — none needed changes:
packages/web/src/pages/feed-page/components/desktop/FeedPageContent.tsxpackages/web/src/pages/feed-page/components/mobile/FeedPageContent.tsxpackages/mobile/src/screens/feed-screen/FeedScreen.tsxTest plan
tsc --noEmit -p packages/common)release-candidate.audius.co):/v1/users/{id}/recommended-tracks?time_range=week&limit=10&offset=0&user_id={id}→ 200 with track data/v1/users/{id}/feed/for-you🤖 Generated with Claude Code