Skip to content

Conversation

@palcu
Copy link
Contributor

@palcu palcu commented Dec 24, 2025

Summary

  • When sending "Significant change" (CP change) emails, skip users who have withdrawn their predictions from ALL questions in a post
  • If a user still has at least one active forecast on any question in the post, they will continue receiving CP change emails

Changes

  • Add helper function get_users_with_active_forecasts_for_questions() that returns user IDs with at least one active forecast (where end_time is NULL or in the future)
  • Modify notify_post_cp_change() to skip users without active forecasts
  • Add tests for the new functionality

Test plan

  • Added unit tests for get_users_with_active_forecasts_for_questions()
    • Users with active forecasts (end_time=None) are included
    • Users with withdrawn forecasts (end_time in past) are excluded
    • Users with future end_time are still considered active
    • Users with at least one active forecast across multiple questions are included

🤖 Generated with Claude Code

When sending "Significant change" (CP change) emails, skip users who
have withdrawn their predictions from ALL questions in a post.

- Add helper function get_users_with_active_forecasts_for_questions()
  that returns user IDs with at least one active forecast
- Modify notify_post_cp_change() to skip users without active forecasts
- Add tests for the new functionality

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@palcu palcu force-pushed the skip-cp-change-emails-for-withdrawn-forecasts branch from dd1dd83 to 108e616 Compare December 24, 2025 14:00
@palcu
Copy link
Contributor Author

palcu commented Dec 29, 2025

From the logs of the integration tests:

[Backend]: django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.

I don't think that's me...

Comment on lines +150 to +155
Forecast.objects.filter(
question_id__in=question_ids,
)
.filter(Q(end_time__isnull=True) | Q(end_time__gt=timezone.now()))
.values_list("author_id", flat=True)
.distinct()
Copy link
Contributor

Choose a reason for hiding this comment

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

@claude Reuse Forecast.objects.active() of ForecastQuerySet

@hlbmtc
Copy link
Contributor

hlbmtc commented Dec 29, 2025

From the logs of the integration tests:

[Backend]: django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.

I don't think that's me...

Thank you. This was an old issue with integration tests on PRs from forks (GitHub <> secrets <> forks) that I’ve just fixed — #3983. Could you please pull the latest changes?

@hlbmtc hlbmtc deployed to testing_env January 2, 2026 16:54 — with GitHub Actions Active
@hlbmtc hlbmtc merged commit 2398fa2 into Metaculus:main Jan 2, 2026
3 checks passed
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.

2 participants