Cap aggregate forecast previews at question close time - #5054
Cap aggregate forecast previews at question close time#5054SylvainChevalier wants to merge 2 commits into
Conversation
The default CP preview on resolved questions used the last aggregate forecast rather than the CP at the point of resolution. When a question is resolved as of a past date, it appears open until the resolution is entered, so aggregate forecasts keep accruing after actual_close_time and the preview showed a value from after the question effectively closed. Cap the "latest" aggregate at actual_close_time (min of actual_resolve_time and scheduled_close_time) in both the query used for feed-card previews and the aggregations serializer used on the detail page, so the default CP reflects the value at resolution/close time. Open questions keep showing the most recent CP. Scores are unaffected: scoring already clamps forecast windows to actual_close_time, so this was a display-only issue. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XgUzpLZNHiVXK3t7UGoSsU
|
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 |
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XgUzpLZNHiVXK3t7UGoSsU
|
Superseded by #5055. This PR's branch name ( Generated by Claude Code |
Summary
Fix the default aggregate forecast ("latest" CP) preview for questions that were resolved retroactively (resolved as of a past date but kept accumulating forecasts until the resolution was entered). The preview now correctly reflects the forecast value at the question's effective close time rather than the most recent forecast.
Key Changes
questions/services/forecasts.py: Updatedget_last_aggregated_forecasts_for_questions()to filter aggregate forecasts byactual_close_time. For open questions (whereactual_close_timeis null), the most recent forecast is used. For closed/resolved questions, only forecasts that started at or beforeactual_close_timeare considered.questions/serializers/aggregate_forecasts.py: Added_get_latest_aggregate_forecast()helper function that selects the appropriate forecast for the "latest" CP preview. It respects theactual_close_timecutoff for closed questions while maintaining full history in serialization.tests/unit/test_questions/test_services/test_forecasts.py: Added comprehensive test suite (TestCPAtResolutionTime) covering:Implementation Details
actual_close_timeis defined asmin(actual_resolve_time, scheduled_close_time), matching the horizon scoring logichttps://claude.ai/code/session_01XgUzpLZNHiVXK3t7UGoSsU