Skip to content

refactor(for-you): back feed's For You tab with /recommended-tracks#14301

Merged
dylanjeffers merged 1 commit into
mainfrom
refactor/for-you-feed-use-recommended
May 13, 2026
Merged

refactor(for-you): back feed's For You tab with /recommended-tracks#14301
dylanjeffers merged 1 commit into
mainfrom
refactor/for-you-feed-use-recommended

Conversation

@dylanjeffers
Copy link
Copy Markdown
Contributor

Summary

The Feed page's For You tab hit a dedicated /v1/users/{id}/feed/for-you endpoint with its own custom server-side ranker. That endpoint had:

Meanwhile, the Explore page's For You section already exists, works fine, and is powered by /v1/users/{id}/recommended-tracks (via useRecommendedTrackssdk.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-you endpoint is being deleted from the API in a companion PR.

What changed

  • packages/common/src/api/tan-query/lineups/useForYouFeed.ts
    • sdk.users.getUserForYouFeed(...)sdk.users.getUserRecommendedTracks(... timeRange: Week)
    • Updated docstring to point at the new endpoint

What stayed the same (intentionally — so consumers don't touch)

Verified consumers — none needed changes:

  • packages/web/src/pages/feed-page/components/desktop/FeedPageContent.tsx
  • packages/web/src/pages/feed-page/components/mobile/FeedPageContent.tsx
  • packages/mobile/src/screens/feed-screen/FeedScreen.tsx

Test plan

  • ✅ Typecheck clean (tsc --noEmit -p packages/common)
  • ✅ Lint clean
  • After deploy on the web RC (release-candidate.audius.co):
    • Signed in, open Feed → For You tab → should show recommended tracks (same content as Explore's For You section)
    • Network: /v1/users/{id}/recommended-tracks?time_range=week&limit=10&offset=0&user_id={id} → 200 with track data
    • No more calls to /v1/users/{id}/feed/for-you
    • Following tab still works (regression check)

🤖 Generated with Claude Code

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>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 13, 2026

⚠️ No Changeset found

Latest commit: e689528

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dylanjeffers dylanjeffers merged commit 9ca80fe into main May 13, 2026
5 checks passed
@dylanjeffers dylanjeffers deleted the refactor/for-you-feed-use-recommended branch May 13, 2026 16:43
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>
@github-actions
Copy link
Copy Markdown
Contributor

🌐 Web preview ready

Preview URL: https://audius-web-preview-pr-14301.audius.workers.dev

Unique preview for this PR (deployed from this branch).
Workflow run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant