Fix: similar questions sidebar tiles not showing user forecasts#4832
Fix: similar questions sidebar tiles not showing user forecasts#4832ncarazon wants to merge 1 commit into
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
| group_cutoff=1, | ||
| include_cp_history=True, | ||
| current_user=request.user if request.user.is_authenticated else None, | ||
| include_user_forecasts=True, |
There was a problem hiding this comment.
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
🚀 Preview EnvironmentYour preview environment is ready!
Details
ℹ️ Preview Environment InfoIsolation:
Limitations:
Cleanup:
|
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_viewwas callingserialize_post_many()withoutinclude_user_forecasts=True, somy_forecastswas never included in the similar posts API response.posts.shared.ts:getSimilarPostsusednext: { 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. Removingrevalidatemakes the request dynamic and auth-bearing — the backend's own 24h Redis cache forget_similar_posts()ensures performance is not impacted.Screenshots
Before
After
Summary by CodeRabbit