feat: add freshness and randomness weights to popular ranking#623
Open
Jeanclaudeaoun wants to merge 2 commits into
Open
feat: add freshness and randomness weights to popular ranking#623Jeanclaudeaoun wants to merge 2 commits into
Jeanclaudeaoun wants to merge 2 commits into
Conversation
Add two new weight parameters for the popular feed ranking system: - freshness: controls time-decay factor (newer posts rank higher) - randomness: controls daily shuffle jitter to prevent stale ordering These are sent as query params to the backend alongside existing weights, where the scoring formula applies time decay and deterministic daily randomness to the base engagement score. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016Q4cZKvz96N3NZmHk2gPhH
✅ Deploy Preview for fancy-gelato-7cdad5 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
🔎️ Preview Link for Commit:
|
Generate a random seed on each page mount and send it as a `seed` query param to /api/posts/popular. The backend uses this to shuffle qualifying posts on every refresh (TikTok "For You" style), while keeping order stable during pagination within the same session. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016Q4cZKvz96N3NZmHk2gPhH
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
freshnessandrandomness) to the popular feed ranking systemfreshnesscontrols time-decay: the backend should apply a decay factor like1/(1 + ageHours/halfLife)^gravityso newer posts rank higherrandomnesscontrols daily shuffle: the backend should apply deterministic daily jitter (e.g. ±20% seeded byhash(postId + todayUTC)) so the same posts don't always appear in the same orderDetails
The frontend already supports 8 weight keys (
comments,tipsAmountAE,tipsCount,uniqueTippers,trendingBoost,contentQuality,reads,interactionsPerHour) sent as query params toGET /api/posts/popular. This PR adds two more:freshness(Date.now - datePosted)— low = weak decay (old posts stay), med = moderate, high = aggressive decay favoring new postsrandomnessBoth default to
med(not sent to backend) like all other weights. Comments are already included as an existing weight key.Files changed
src/features/social/components/SortControls.tsx— addedfreshnessandrandomnesstoWeightKeytype and label mapsrc/api/backend.ts— added new keys to the weights type inlistPopularPosts()src/locales/en.json— added translation stringsBackend requirements
The backend (
/api/posts/popular) needs to handle these two new query params and incorporate them into the scoring formula. Suggested approach:Test plan
backend.listPopularPosts.test.ts— verifies new weight keys are appended to URLSortControls.test.tsx— verifies 10 weight labels render with low/med/high toggles🤖 Generated with Claude Code
https://claude.ai/code/session_016Q4cZKvz96N3NZmHk2gPhH
Generated by Claude Code
Note
Low Risk
Frontend-only query-param and UI changes; correct ranking depends on backend support for the new weights and seed.
Overview
Extends the popular feed ranking controls and API with two new tunable weights—Freshness and Shuffle (
randomness)—alongside the existing eight signals, wired throughSortControls,listPopularPosts, and English copy.The client now sends an optional
seedquery param onGET /api/posts/popular. The hot feed keeps a sessionshuffleSeedref, includes it in the React Query key, and passes it on every popular-posts fetch so pagination stays consistent with backend shuffle behavior.Tests cover the new weight query params and seed append/omit behavior; SortControls tests expect 10 weight rows (labels Freshness / Shuffle).
Reviewed by Cursor Bugbot for commit aceb201. Bugbot is set up for automated code reviews on this repo. Configure here.
📸 Screenshots report — updated Tue, 14 Jul 2026 00:44:39 GMT