Repository navigation
Add X like velocity to the paper trending score - #867
Merged
Merged
Conversation
New hourly CRON `refresh_x_post_likes` tracks linked X posts during their first week in `x_post_metrics`: syndication first, paid X API fallback capped at 300 posts/day, likes-per-hour EMA on a decaying schedule. The paper score job adds the quantile rank of each paper's fastest post as a third component, weighted by PWC_TRENDING_X_WEIGHT (default 0, so rankings are unchanged). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f80c0b1. Configure here.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
Status (2026-11-03 09:55 UTC): live in production as
|
This was referenced Nov 3, 2026
NielsRogge
added a commit
that referenced
this pull request
Nov 5, 2026
X like velocity now lifts papers in the main trending score (#867, #871, PWC_TRENDING_X_WEIGHT=1 since 2026-11-05), so the separate tab is gone: /x-trending redirects to /, and GET /papers/x-trending, XTrendingService.feed() and papersApi.xTrending are removed. The admin PUT /papers/x-trending/{day} and the paper_x_trending table stay for the sheet routine and curation priority. Co-authored-by: Claude Opus 5.5 <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.

First step toward merging
/and/x-trending. This adds X like velocity as a third part of the paper trending score. Its weight defaults to 0, so deploying this changes no rankings.What it does
refresh_x_post_likes(:35). Each run adds anx_post_metricsrow for everypaper_x_threadspost from the last 7 days. It then reads each post about 1, 2, 4, 8, 12, 24, 48, 72, 120 and 144 h after posting and keeps an EMA of likes per hour (α = 0.75, as for GitHub). The first reading uses the lifetime average.GET /2/tweets?ids=lookups in batches of 100.PWC_X_LIKES_API_DAILY_CAP(default 300) posts per UTC day.gone_at.PWC_X_LIKES_APPLY=true.calculate_paper_trending_scorestakes each paper's fastest live post and ranks it against the other papers' fastest posts. Posts underPWC_TRENDING_X_MIN_LIKES_PER_HOUR(default 1) count for nothing and are left out of that ranking. The result is weighted byPWC_TRENDING_X_WEIGHT; GitHub and HF share the rest equally (w_g = w_h = (1 − w_x)/2), so the score stays within 0–100 and pins keep working. The X part is stored inpapers.x_trending_component.pwc_cron_trendinggets SELECT onpaper_x_threadsandx_post_metrics, and UPDATE onpapers.x_trending_component. This is done in bothconfigure_db_roles.pyand the migration. The launcher passes the twoPWC_TRENDING_X_*settings through, andconfigure_host_env.pykeeps them when it rewritestrending-cron.env.Migration
backend/database/migrations/add_x_post_metrics.sqlwas already applied topublic(2026-11-03 09:35 UTC) before merge. It useslock_timeout = 10sfor thepaperscolumn.Verification
pytest backend/tests/test_x_post_likes_service.py backend/tests/test_trending_formula.py backend/tests/paper/test_trending_scores.py backend/tests/cron backend/tests/deployment/test_cron_environment.pygives 270 passed and 1 failure. That failure,test_cron_jobs_declare_bounded_execution_contracts, is not from this PR: it fails because oflink_google_scholar_profiles' existing3htimeout.ruff checkandruff formatare clean.x_post_metricsstill empty). Median 0.82 likes/h, 90th percentile 14, 33 posts ≥ 1/h, max 3,040/h.Rollout (after deploy)
PWC_X_LIKES_APPLY=trueinproduction-cron.envand enable the timer./and/x-trending.PWC_TRENDING_X_WEIGHT=0.3333intrending-cron.env./x-trendingto/, and dropsGET /papers/x-trending.🤖 Generated with Claude Code
Note
Medium Risk
Changes paper trending formula and DB writes when X weight or apply flags are enabled; external X API usage and capped paid fallback add operational and cost failure modes, though default weight 0 limits ranking impact on deploy.
Overview
Adds an optional third signal for composite paper trending: smoothed likes-per-hour on linked
paper_x_threadsposts, wired end-to-end from collection through scoring and ops.New pipeline: Hourly
refresh_x_post_likes(:35) enrolls posts from the last 7 days intox_post_metrics, reads them on a decaying schedule (1–144h), prefers embed syndication, falls back to paid X API with a daily cap, and supports report-only mode (PWC_X_LIKES_APPLY) that rolls back DB writes.calculate_paper_trending_scoresloads each paper’s fastest live post, quantile-ranks it (posts belowPWC_TRENDING_X_MIN_LIKES_PER_HOURexcluded), blends viaPWC_TRENDING_X_WEIGHTwhile GitHub/HF share(1 − w_x)/2, and persistspapers.x_trending_component.DEFAULT_X_WEIGHTis 0, so production rankings stay unchanged until operators raise the weight.Schema & access: Migration adds
x_post_metricsandpapers.x_trending_component;pwc_cron_trendingand env tooling gain SELECT/UPDATE grants and passthrough forPWC_TRENDING_X_*/PWC_X_LIKES_*. Cron registry, systemd units, launcher, health docs, and tests are updated accordingly.Reviewed by Cursor Bugbot for commit 2c917a8. Bugbot is set up for automated code reviews on this repo. Configure here.