Skip to content

Conversation

@elisescu
Copy link
Contributor

@elisescu elisescu commented Nov 3, 2025

The question should either be more than 2 weeks old, or have at least 20 forecasters

Closes #3725

is_above_2_weeks = question_age >= timedelta(days=14)

is_open = question.status == QuestionStatus.OPEN
forecasters_count = question.get_forecasters().count()
Copy link
Contributor

@hlbmtc hlbmtc Nov 4, 2025

Choose a reason for hiding this comment

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

This will introduce an N+1 query and could lead to performance issues, especially since it’s used in serialize_question_movement, which gets called in many places where we render multiple questions at once

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch

The question should either be more than 2 weeks old, or have at least 20 forecasters
forecasts_count=SubqueryAggregate("forecast", aggregate=Count)
)

def annotate_forecasters_count(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

This makes sense, but I do have some concerns about the potential performance overhead.

Ideally, we could introduce a cached field on the Question model (similar to Post.forecasters_count and Post.update_forecasters_count) that's updated during the forecasting process. That way, we avoid recalculating it repeatedly, and it could also be useful for other features.

WDYT?

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.

Don't show Community Prediction movement when question is under 2 weeks or 20 forecasters

3 participants