Skip to content

Commit f3f211a

Browse files
dylanjeffersclaude
andauthored
chore: remove /v1/users/{id}/feed/for-you endpoint (#807)
## 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>
1 parent 276fdeb commit f3f211a

5 files changed

Lines changed: 2 additions & 950 deletions

File tree

api/auth_middleware.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -347,16 +347,8 @@ func (app *ApiServer) authMiddleware(c *fiber.Ctx) error {
347347
return fiber.NewError(fiber.StatusUnauthorized, "Invalid or expired access token")
348348
}
349349

350-
// Not authorized to act on behalf of myId.
351-
//
352-
// Exception: /users/:userId/feed/for-you accepts user_id as a viewer hint
353-
// used only for response decoration (has_current_user_reposted etc.); the
354-
// path :userId — not user_id — controls what gets personalized. Treat the
355-
// query user_id as advisory rather than authoritative on this route so
356-
// the endpoint can be called like the other public read endpoints.
357-
allowUnauthenticatedViewerId := strings.HasSuffix(c.Path(), "/feed/for-you")
358-
359-
if myId != 0 && !pkceAuthed && !allowUnauthenticatedViewerId && !app.isAuthorizedRequest(c.Context(), myId, wallet) {
350+
// Not authorized to act on behalf of myId
351+
if myId != 0 && !pkceAuthed && !app.isAuthorizedRequest(c.Context(), myId, wallet) {
360352
return fiber.NewError(
361353
fiber.StatusForbidden,
362354
fmt.Sprintf(

api/server.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,6 @@ func NewApiServer(config config.Config) *ApiServer {
453453
g.Get("/users/:userId/contests", app.v1UserContests)
454454
g.Get("/users/:userId/playlists", app.v1UserPlaylists)
455455
g.Get("/users/:userId/feed", app.v1UsersFeed)
456-
g.Get("/users/:userId/feed/for-you", app.v1UsersFeedForYou)
457456
g.Get("/users/:userId/connected_wallets", app.v1UsersConnectedWallets)
458457
g.Get("/users/:userId/transactions/audio", app.v1UsersTransactionsAudio)
459458
g.Get("/users/:userId/transactions/audio/count", app.v1UsersTransactionsAudioCount)

api/swagger/swagger-v1.yaml

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -9433,76 +9433,6 @@ paths:
94339433
"500":
94349434
description: Server error
94359435
content: {}
9436-
/users/{id}/feed/for-you:
9437-
get:
9438-
tags:
9439-
- users
9440-
summary: Get For You feed for user
9441-
description:
9442-
Returns a personalized For You feed for the user identified in the
9443-
path. Twitter-style multi-source pipeline — candidate retrieval
9444-
(in-network, trending, underground, similar-artist) → linear
9445-
ranking (recency decay × engagement × social affinity, weighted
9446-
by source) → diversity (per-artist cap + consecutive-same-artist
9447-
lookahead).
9448-
operationId: Get User For You Feed
9449-
security:
9450-
- {}
9451-
- OAuth2:
9452-
- read
9453-
parameters:
9454-
- name: id
9455-
in: path
9456-
description: A User ID
9457-
required: true
9458-
schema:
9459-
type: string
9460-
- name: limit
9461-
in: query
9462-
description: The number of items to fetch
9463-
schema:
9464-
type: integer
9465-
default: 25
9466-
minimum: 1
9467-
maximum: 100
9468-
- name: offset
9469-
in: query
9470-
description:
9471-
The number of items to skip. Useful for pagination (page number
9472-
* limit)
9473-
schema:
9474-
type: integer
9475-
default: 0
9476-
minimum: 0
9477-
maximum: 200
9478-
- name: max_per_artist
9479-
in: query
9480-
description:
9481-
Maximum number of tracks per artist on a single page. Used by the
9482-
diversity pass to cap consecutive same-artist results.
9483-
schema:
9484-
type: integer
9485-
default: 3
9486-
minimum: 1
9487-
maximum: 10
9488-
- name: user_id
9489-
in: query
9490-
description: The user ID of the user making the request
9491-
schema:
9492-
type: string
9493-
responses:
9494-
"200":
9495-
description: Success
9496-
content:
9497-
application/json:
9498-
schema:
9499-
$ref: "#/components/schemas/tracks"
9500-
"400":
9501-
description: Bad request
9502-
content: {}
9503-
"500":
9504-
description: Server error
9505-
content: {}
95069436
/users/{id}/library/albums:
95079437
get:
95089438
tags:

0 commit comments

Comments
 (0)