Skip to content

Fix: similar questions sidebar tiles not showing user forecasts#4832

Open
ncarazon wants to merge 1 commit into
mainfrom
fix/similar-questions-sidebar-user-forecasts
Open

Fix: similar questions sidebar tiles not showing user forecasts#4832
ncarazon wants to merge 1 commit into
mainfrom
fix/similar-questions-sidebar-user-forecasts

Conversation

@ncarazon
Copy link
Copy Markdown
Contributor

@ncarazon ncarazon commented Jun 4, 2026

Resolves #4792

Summary

Sidebar similar question tiles were not displaying the user's own forecast ("Me: X%"), even though the main feed tiles showed them correctly.

Implemented changes:

  • posts/views.py: post_similar_posts_api_view was calling serialize_post_many() without include_user_forecasts=True, so my_forecasts was never included in the similar posts API response.

  • posts.shared.ts: getSimilarPosts used next: { revalidate: 1800 }, which triggers a security guard in the server fetcher that intentionally strips the auth token from cached requests to prevent leaking user-specific data across a shared cache. Without the auth token, the backend treats the request as unauthenticated and skips user forecast data regardless of the backend fix. Removing revalidate makes the request dynamic and auth-bearing — the backend's own 24h Redis cache for get_similar_posts() ensures performance is not impacted.

Screenshots

Before

image (11)

After

image (12)

Summary by CodeRabbit

  • New Features
    • Similar posts recommendations now include personalized user forecast data, providing users with additional forecasting context alongside related content suggestions.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 4, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5ef42669-c83c-4111-bbc0-2f85fe552d00

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/similar-questions-sidebar-user-forecasts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment thread posts/views.py
group_cutoff=1,
include_cp_history=True,
current_user=request.user if request.user.is_authenticated else None,
include_user_forecasts=True,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Highlighting this for BE engineer to review. Without include_user_forecasts=True, the similar posts endpoint always returns unauthenticated responses – omitting my_forecasts from the payload and causing sidebar tiles to never show the user's own forecast

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

🚀 Preview Environment

Your preview environment is ready!

Resource Details
🌐 Preview URL https://metaculus-pr-4832-fix-similar-questions-sidebar-preview.mtcl.cc
📦 Docker Image ghcr.io/metaculus/metaculus:fix-similar-questions-sidebar-user-forecasts-3d3a7e9
🗄️ PostgreSQL NeonDB branch preview/pr-4832-fix-similar-questions-sidebar
Redis Fly Redis mtc-redis-pr-4832-fix-similar-questions-sidebar

Details

  • Commit: 18ec76be67662fabf968bae369ffdaf502f70dde
  • Branch: fix/similar-questions-sidebar-user-forecasts
  • Fly App: metaculus-pr-4832-fix-similar-questions-sidebar

ℹ️ Preview Environment Info

Isolation:

  • PostgreSQL and Redis are fully isolated from production
  • Each PR gets its own database branch and Redis instance
  • Changes pushed to this PR will trigger a new deployment

Limitations:

  • Background workers and cron jobs are not deployed in preview environments
  • If you need to test background jobs, use Heroku staging environments

Cleanup:

  • This preview will be automatically destroyed when the PR is closed

@ncarazon ncarazon marked this pull request as ready for review June 4, 2026 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Main feed question tiles show my forecasts, but question page sidebar tiles do not

1 participant